Problem with environment variable-named directories

Please report only one bug per message!

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Bluestar
Senior Member
Senior Member
Posts: 377
Joined: 2007-06-10, 15:26 UTC
Location: Hungary
Contact:

Problem with environment variable-named directories

Post by *Bluestar »

Steps to reproduce:

01. Create a directory inside Total Commander (F7) with the name %NUMBER_OF_PROCESSORS% (or %OS%, etc).
02. Type the following to the command line of Total Commander: cd %NUMBER_OF_PROCESSORS%
03. No effect - Total Commander automatically replaces the %NUMBER_OF_PROCESSORS% to 2 (in my case), and since the directory called "2" doesn't exists at all, nothing happens.

Tested under Windows 7 SP1, with TC versions: 7.56a & 8.0b10.

Edit: also theres no effect if you manually edit the path (by double clicking the current path, and copy-pasting "c:\%NUMBER_OF_PROCESSORS%") - TC fails to enter the directory (the only way it works is the breadcrumb bar, or by manually pressing an enter on it).
» Developer of Total Updater & extDir utility.
User avatar
petermad
Power Member
Power Member
Posts: 14794
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Who in their right mind will use the name of a system environment variable as a folder name ? ;-) (or any environment variable for that matter).

IMHO TC just does, what you tell it to do: resolves the env. var. %NUMBER_OF_PROCESSORS% and tries to go to a directory with he resolved value.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Bluestar
Senior Member
Senior Member
Posts: 377
Joined: 2007-06-10, 15:26 UTC
Location: Hungary
Contact:

Post by *Bluestar »

Ahem... me? :mrgreen:

Anyway i see your point, as i found this bug by an accident while developing an external TC utility - however i think this isn't the way Total Commander should work in this case (as i haven't told TC to resolve the environment variable, it happened automatically)...

I mean if you create two folders:

c:\2 (if you actually have 2 cores)
c:\%NUMBER_OF_PROCESSORS%

... and type cd %NUMBER_OF_PROCESSORS% to the command line of TC, it should check if the directory after "cd" command exists or not in the current path:

- a) %NUMBER_OF_PROCESSORS% exists - enter to the directory (do not resolve it)
- b) %NUMBER_OF_PROCESSORS% doesn't exists - lets resolve the environment variable (if possible), and check if a dir with the name of the resolved value exists or not (enter to the dir in case it exists)
- c) none of them exists - do nothing

Instead of the above, if you type the command and press enter (and a directory called "1" or "2" and "%NUMBER_OF_PROCESSORS%" exists in the same place), Total Commander enters into "1" or "2" - and thats not what the user told to do.

So i have one question: put the case that i really need this %NUMBER_OF_PROCESSORS% folder - how can i enter into it using Total Commander's command line?
» Developer of Total Updater & extDir utility.
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

So i have one question: put the case that i really need this %NUMBER_OF_PROCESSORS% folder - how can i enter into it using Total Commander's command line?
Configuration->Options-> Misc.
(x) alias: cdd
[magnifier button] -> [New] enter em_cd
under commands enter cd
[ok] [ok] [green checkmark button]
command line wrote:cdd %%NUMBER_OF_PROCESSORS%%
:wink:
Holger
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

None of the normal cmd.exe methods work, directly from the command-line.

I recall this was discussed in at least one thread that MVV and I partook in.

This is how a real command prompt handles it:

1) CD %"USERNAME"%
---> will change dir to %USERNAME% - not resolved as a variable.

2) CD ^%USERNAME^%
---> again, will not resolve the Environment variable.

TC treats both of those as "valid" folder names, and doesn't find them. Instead of ignoring the quote and or caret, and treating the first one as a valid way to block environment variable expansion.
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Indeed in the command line, environment variables are always resolved. I don't currently have any plans to change that. You can enter the folder by double clickibg or with the ENTER key, though.
Author of Total Commander
https://www.ghisler.com
User avatar
Bluestar
Senior Member
Senior Member
Posts: 377
Joined: 2007-06-10, 15:26 UTC
Location: Hungary
Contact:

Post by *Bluestar »

@ghisler(Author):
But not programatically (for example by using WM_COPYDATA message) from an external tool.

Anyway i see, so the point is theres actually no clean way of doing that, and that won't change within reasonable time - thanks to everyone for the replies.

@HolgerK:
Nice workaround, thank you - this way it works like a charm. The only fly in the ointment is that it needs an extra usercmd option, but thats not a big deal in my case...
» Developer of Total Updater & extDir utility.
Post Reply