Allow expanding empty envvars in command line/BAR/USERCMD

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Allow expanding empty envvars in command line/BAR/USERCMD

Post by *MVV »

Currently TC doesn't expand envvar if its value is empty string, it just leaves %var% in a string, and this causes execution errors. I've checked, ExpandEnvironmentStrings system function does expand such vars properly, e.g. it expands %COMMANDER_PATH%\Tools\Program\Program%EMPTY_OR_64%.exe to D:\TOTALCMD\Tools\Program\Program.exe when EMPTY_OR_64 variable is set to empty string.

I know that empty variables can only be set with some third-party tools or plugins that call SetEnvironmentVariable function but sometimes it is really handy to have them when you want to e.g. start 64-bit programs under 64-bit Windows and 32-bit under 32-bit one.

E.g. one can use Autorun content plugin for auto-setting such variables depending on Windows bitness:

Code: Select all

LoadLibrary Plugins\Autorun_Sysinfo.dll

If %SYSINFO_OSARCH% = 32 Then
	SetEnv OS_EMPTY_OR_64
	SetEnv OS_EMPTY_OR_64_SLASH
Else
	SetEnv OS_EMPTY_OR_64 64
	SetEnv OS_EMPTY_OR_SLASH_64 \64
EndIf

If %AUTORUN_TCARCH% = 32 Then
	SetEnv TC_EMPTY_OR_64
	SetEnv TC_EMPTY_OR_64_SLASH
Else
	SetEnv TC_EMPTY_OR_64 64
	SetEnv TC_EMPTY_OR_SLASH_64 \64
EndIf
And then such variables may be used in BAR/USERCMD e.g. for launching binaries with names ending with 64 or ones that are placed to 64\ subdir of TC dir:

Code: Select all

Command=%COMMANDER_PATH%\Tools\Program\Program%OS_EMPTY_OR_64%.exe

Code: Select all

Command=%COMMANDER_PATH%%TC_EMPTY_OR_SLASH_64%\Program.exe
Or from command line:

Code: Select all

Program%OS_EMPTY_OR_64%.exe
Please make it working. It won't break anything because it is not so trivial to set such variables.
User avatar
LonerD
Senior Member
Senior Member
Posts: 381
Joined: 2010-06-19, 20:18 UTC
Location: Makeyevka, Russia
Contact:

Re: Allow expanding empty envvars in command line/BAR/USERCMD

Post by *LonerD »

MVV wrote: 2018-05-22, 05:33 UTCE.g. one can use Autorun content plugin for auto-setting such variables depending on Windows bitness:
I use ^. Many commands related to empty variable.
It's works in TC 9.12 and early versions, but now in TC 9.20 my commands are totally broken. :(
Please, return previous functionality.
"I used to feel guilty in Cambridge that I spent all day playing games, while I was supposed to be doing mathematics. Then, when I discovered surreal numbers, I realized that playing games IS math." John Horton Conway
Post Reply