Quoting file names with special characters?

May 20, 2008
11,407
99
Syracuse, NY, USA
I don't know if this is a good idea or not.

What if "DO f in ... fileset ( ... )" were to automatically quote %f when it contains special characters?
 
May 20, 2008
11,407
99
Syracuse, NY, USA
That was the original behavior. And then the beta testers (that would be you!) complained that the auto-quoting made it difficult to pass the returned value on to other functions / commands.
That doesn't sound like me, but in any case ...

Commands will certainly have a problem if an unquoted file name contains special characters. What about variable functions? Are there ones that expect/require a file name but won't work correctly if it's quoted?
 

rps

Jul 6, 2008
436
6
That doesn't sound like me, but in any case ...

Commands will certainly have a problem if an unquoted file name contains special characters. What about variable functions? Are there ones that expect/require a file name but won't work correctly if it's quoted?
Not just "special" characters, but directories with spaces. I installed V22 in a directory named "TCMD V22" and that has necessitated changes to many of my scripts.
The DO loops where especially troublesome until I read the docs more carefully. Quoting the resulting variable has solved that and works quit well so far.

I haven't encountered any problems using quotes in variable functions yet, have you?
 
May 20, 2008
11,407
99
Syracuse, NY, USA
I haven't encountered any problems using quotes in variable functions yet, have you?
Not in functions that expect a file name (but I didn't do an exhaustive search). As expected, generic string functions (like @LEN) treat the quotes as significant.
 

rps

Jul 6, 2008
436
6
Not in functions that expect a file name (but I didn't do an exhaustive search). As expected, generic string functions (like @LEN) treat the quotes as significant.
That's a very good argument for not having DO arguments automatically quoted.
For example;
Code:
v22.00.31_$*echo %_cmdspec
D:\TCMD v22\TCC.EXE

v22.00.31_$do var in "%_cmdspec" (echo %var & echo %@len[%var])
D:\TCMD v22\tcc.exe
19

v22.00.31_$do var in /L %_cmdspec (echo %var & echo %@len[%var])
D:\TCMD
7
v22\TCC.EXE
11

v22.00.31_$do var in /t"" /L %_cmdspec (echo %var & echo %@len[%var])
D:\TCMD v22\TCC.EXE
19
Not an extensive example, but it does illustrate the point. I have scripts and aliases that use other variable functions, some needing quotes and some not. Just have to be careful of the intended use and quote where required for a correct result.
Perhaps someone would like to invest the time to write an exhaustive btm to test all the permutations. Considering the extensive number of variables and functions in TCC this could be a very time consuming exercise or not. :rolleyes:
 
Similar threads
Thread starter Title Forum Replies Date
fpefpe quoting Support 6
fpefpe How to? Quoting Support 2
vefatica Quoting? Support 11
vefatica Quoting @Function parameters? Support 0
gschizas How to? Advanced quoting (for awk) Support 2
S Suggestion: enhanced automatic quoting of filenames Support 2
p.f.moore Quoting arguments to a user defined function Support 4
J History file load hangs if file has complete garbage in it... Support 1
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
thorntonpg file explorer - short cut keys Support 1
JohnQSmith New online help file wrong logo Support 7
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
samintz How to? swap endianness in a binary file Support 12
vefatica `Back quotes` - command line vs. batch file Support 5
fpefpe How to? batch file size Support 2
Jay Sage Issues With TCMD File Explorer Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
Joe Caverly @FILESIZE and NTFS File Stream Support 1
Joe Caverly Embedding an .EXE (or other file) into a .BTM Support 8
U Command help on file names Support 5
S Concatenate all playlists into 1 file Support 22
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
Joe Caverly Rename file that begins with Emoji Support 7
Joe Caverly PSHELL and NTFS File Streams Support 2
P Kill all other instances of tcc from a btm batch file Support 2
D ffind hangs on large file Support 18
Alpengreis Documentation Minor issue in help file for view /E Support 1
fpefpe batch file ending early Support 18
J Licesne file location Support 1
K robocopy cancelling batch file processing Support 28
Jay Sage TCMD Crashes with "tctoolbar /c /r file" Support 5
A Unable to pass batch file arguments unaltered Support 18
MikeBaas How to...extract a string from a .json-file? Support 10
vefatica LIBRARY and file name completion? Support 4
D What does the file "..\Everything\Run history.csv" store? Support 5
H Takecommand.pdf failed not a pdf file Support 6
Joe Caverly DIRectory Colorization in v25 Help File Support 0
C show file description? with dir? Support 8
D When copying/moving, appending " (2)" to filename when the target file already exist. Support 7
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
Joe Caverly _EXPANSION in help file Support 0
Stefan Hassel Installation file TC 24.02 Build 47 is actually version 25.00.1 Support 10
vefatica Are @FILEDATE[file] and @FILEDATE[file,u] ever different? Support 2
K_Meinhard Help file error Support 1
Joe Caverly JOBMONITOR in Help File Support 1
D btm file command line augments comparing for string or math. Support 12
A Documentation [Help file] OPTION "//" synopsis formatting issue Support 0
vefatica Can TCC complete this file name? Support 5
G tcedit ist not run in tc 24 file explorer Support 10
M How to set Path variable for non-executable file extensions in 4DOS Support 8

Similar threads