TCC 20 variable expansion bug

May 30, 2008
235
2
I was just testing "TCC 20.11.46 x64 Windows 10 [Version 6.3.14393]" and noticed some of my find scripts no longer worked compared to TCC 15.

Simplified reproduction below:

Code:
@echo off

set re=(?i-)str
set filename="C:\filename.txt"

echo ffind /e"%re%" %filename%

TCC 20 will print out: ffind /e"(?i-)str" %filename%

TCC 15 will print out: ffind /e"(?i-)str" "C:\filename.txt"

Obviously the latter is what I want. :)

What went wrong with TCC 20? Is it a bug, or am I doing it wrong somehow?
 
May 20, 2008
11,411
99
Syracuse, NY, USA
It does look like something is wrong, but here, it's no better with v15.
Code:
v:\> type eff.btm
@echo off
ver
set re=(?i-)str
set filename="C:\filename.txt"
echo ffind /e"%re%" %filename%

v:\> eff.btm

TCC  15.01.58   Windows 7 [Version 6.1.7601]
ffind /e"(?i-)str" %filename%
 
May 30, 2008
235
2
Interesting.

I use version 15.00.34 x64 of v15 so a little older. Apparently something changed shortly after that then.

The problem seems to be that the parentheses somehow interfere with the parsing/expansion.

Should maybe find some other way to include them in the regular expression for the /E switch of FFIND?
 
May 20, 2008
11,411
99
Syracuse, NY, USA
Should maybe find some other way to include them in the regular expression for the /E switch of FFIND?
It goes well beyond FFIND and regular expressions.
Code:
v:\> set zz=(a)

v:\> set yy=b

v:\> echo %zz %yy
(a) b

v:\> echo "%zz" %yy  <================?????????????
"(a)" %yy

v:\> echo "(a)" %yy
"(a)" b
 
May 30, 2008
235
2
I added a work-around to my script so now it works for me with the newer versions as well.

Previously I used:

Code:
....
ffind %ffindargs% /e"%re%" %filenames%

Where the "re" variable was constructed according to the passed parameters and often contained parenthesis. When this was the case the "filenames" variable was not expanded.

The new work-around code is simply:

Code:
....
set re="%re%"
ffind %ffindargs% /e%re% %filenames%

This way the "filenames" variable is properly expanded.

Still, would be interesting to know why the old way did not work. Seems correct to me, but I will not pretend to understand all the intricacies of TCC/CMD command line parsing. Quite a lot of edge-cases!
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
The problem is because the leading ( causes the parser to think it's processing a command group. The trailing double quotes don't match up so the parser assumes that everything following the first trailing double quote shouldn't be expanded.

I have a workaround for this syntax in the next build of v21 & beyond. I doubt it will be back-ported to prior versions like v20.
 
May 30, 2008
235
2
Thanks for the info, and no need for back-porting to v20. I will upgrade to v21 or newer at some point, and the current work-around is good enough for now.
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
R Difference between TCC and CMD: variable names with hyphens Support 4
B WAD environment variable in TCC.exe Support 2
MickeyF TCC crashing when copying multiple files (now resolved) Support 6
C COMSPEC constantly reset to TCC.EXE Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
C How to? starting TCC/TCMD v25 Support 2
CWBillow TCC and TCMD in Powershell Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
L FTYPE in TCC, less quirky than in cmd.exe Support 3
V Set path permanently from within TCC? Support 3
DrusTheAxe Runaway TCC.exception.log filling drive Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
Joe Caverly tcc.exception.log Support 3
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
vefatica SCRIPT ... TCC disappears Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
Jesse Heines Access Denied errors in TCC 27 Support 9
fpefpe How to? tcc inifile (%_ininame) Support 3
M How to? Black TCC Prompt Support 2
D Differences between TCC and CMD with COPY /b Support 4
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
Jay Sage Extra TCC Tasks Support 6
vefatica Can I turn off the minimize to tray mechanism in TCC? Support 5
N Command execution slows down in TCC Prompt after a while Support 6
R Upgrade TCMD 19 to TCC 26 Support 1
samintz How to? Is this doable in TCC? Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT 26.02.41 Uploaded Support 0
D TCC tab detaching & restarting Support 3
Ó Recent git output not shown on TCC Support 1
P Kill all other instances of tcc from a btm batch file Support 2
L Using TCC.exe through an SSH connection Support 3
M TCC color issue in ConEmu Support 4
Alpengreis UTF-8 problem in TCC related to Python Support 7
Alpengreis Python support for 3.8.3 in TCC v26.x? Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT 26.01.40 uploaded Support 0
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 26.0.37 Uploaded Support 0
vefatica TCC waits for Office apps Support 4
Joe Caverly .BAT works in TCC-RT 25, but not in TCC-RT 26 Support 4
M Strange error messages from TCC in FTP copy Support 7
Kachupp Documentation tcc-rt versions Support 1
V Comments from a first-time user (TCC 26) Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT 26.0.28 Support 0
C TCC 26 BATCOMP BTM problems? Support 5

Similar threads