Allow expanding empty envvars in command line/BAR/USERCMD
Posted: 2018-05-22, 05:33 UTC
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:
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:
Or from command line:
Please make it working. It won't break anything because it is not so trivial to set such variables.
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
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
Code: Select all
Program%OS_EMPTY_OR_64%.exe