Help making a CMD and TCC compatible batch file

Jan 17, 2021
I'm working with a CMD batch file that uses the satatement:

FOR /F "tokens=1-2" %%i IN ('"git show -s --format=%%%ci HEAD 2> NUL"') do (
   set REV3=%%i%%j

It works fine in CMD, but in TCC, Rev3 is not set (or set to nothing).

I haven't been able to find any way to write this so that it works in TCC - I think it has to do with the %'s - but I'd like to find a way that is fully compatible with CMD and TCC.

Any ideas?
Jan 17, 2021
I should probably point out that at the command line:
git show -s --format=%%ci HEAD
2021-01-14 15:44:20 -0700

I know I could escape the % and that works in CMD and TCC, a al:
git show -s --format=^%ci HEAD

And that works in CMD, but still nothing in TCC.
Apr 2, 2011
North Carolina, USA
If it works in CMD and not in TCC - you might want to look at this:

TCC Compatibility with CMD

There are two options you should set if you regularly run batch files created for CMD:

OPTION / Startup / Duplicate CMD.EXE bugs (This is the default, and tells TCC to duplicate two bugs in CMD's IF command parsing.)

OPTION / Startup / CMD.EXE delayed expansion (If you have this startup option set for your CMD environment.)
Jan 17, 2021
I've now read the compatibility notes - tried setting "CMDVariables=yes" and didn't see a difference.

More research seems to show that the quotes are causing some problems:

FOR /F "tokens=1-2" %%i IN ('dir') do ( echo %%i %%j )

Works fine in both TCC and CMD, but:

FOR /F "tokens=1-2" %%i IN ('"dir"') do ( echo %%i %%j )

Works in CMD, but TCC gives:

TCC: Unknown command "dir"
Jan 17, 2021
Without the quotes, CMD messes up the escaping of the program parameter that requires "%ci" and the redirect doesn't seem to work either way without the quotes.

These scripts are in the bowels of some build systems, and I'm typically the only one that uses TCC, so my solution for now is to set ComSpec to cmd.exe and forget about it. But it would sure be nice not to have to do that.


Scott Mintz
May 20, 2008
Solon, OH, USA
You can split the command and for loop into separate statements.
git show -s --format=%%ci HEAD 2> NUL >temp.txt
for /f "tokens=1-2" %%i in (temp.txt) do set REV3=%%i%%j
Similar threads
Thread starter Title Forum Replies Date
C Add link to ewriter help to program group... Support 3
samintz How to? Search for %(command) in Help? Support 1
Joe Caverly Favorites in eWriter Help Support 6
Joe Caverly Quick Search in eWriter Help Support 1
vefatica Online help? Support 2 HELP!! I just updated to Version 28 and as usual I cannot make extended directory search work. Support 2
JohnQSmith New online help file wrong logo Support 7
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
Charles Dye More help nits Support 0
D Documentation Typo in COPY help Support 0
Joe Caverly Documentation COMMANDS in Version 27 help Support 8
K_Meinhard How to? Help window position Support 7
U Command help on file names Support 5
D Documentation Help "Startup" page does not describe global lists Support 0
vefatica Help disappears? Support 6
rchapmanitt Help Purchasing Support 2
Charles Dye Documentation Help nits: @ZIPFILECRC Support 0
C version help Support 3
C Documentation Help Nit. REN / RENAME Support 0
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
vefatica Help for @PID Support 2
vefatica Need help with XML Support 3
Alpengreis Documentation Minor issue in help file for view /E Support 1
R Documentation Advanced Directives Help Support 0
R Documentation Help Nit with SETP Support 0
R wmic command help Support 9
R Documentation Help Nit > bdebugger View Menu Support 0
R Documentation A couple of Help nits Support 0
R Documentation Help typo Support 1
MikeBaas How to? I need help with RD Support 5
R Documentation v25 Help Comments Support 1
Joe Caverly DIRectory Colorization in v25 Help File Support 0
vefatica Help nit Support 0
D error in help documentation? Support 0
Joe Caverly _EXPANSION in help file Support 0
K_Meinhard Help file error Support 1
Joe Caverly JOBMONITOR in Help File Support 1
A Documentation [Help file] OPTION "//" synopsis formatting issue Support 0
D The local HELP viewer... Support 0
Chen Touboul Overtyping issue - i press the Insert key, help till press enter for new line in TCC Support 2
C Documentation Help nix ZIP /M Support 0
Joe Caverly v24 Help File - DATEMONITOR Support 1
Joe Caverly 7zip command links to zip help Support 0
K_Meinhard Help problems Support 3
Charles Dye Documentation Help Nits Forever: Checksum functions Support 0
Joe Caverly SAVECONSOLE in Help File Support 0
Joe Caverly CMDebug v23 Help: /FEEDBACK /UPDATE Support 0
Joe Caverly CMDebug v23 Help: Link to MOUNTVHD goes to MOUNTISO in UNMOUNTVHD Support 0
Joe Caverly Help not launching in CMDebug v23.00.14 x64 Support 1
Joe Caverly TASKDIALOG Help link error Support 1

Similar threads