Can TCC complete this file name?

May 20, 2008
9,431
63
Syracuse, NY, USA
I got this file name from another thread.
Code:
v:\> dir /k /m (*
2019-03-06  12:33              26  ()%!^&;, .bat
I have two problems. First, I can't type a partial name and have it completed reasonably.
Code:
(<tab>
turns into
Code:
("()%!^&;, .bat"
Code:
"(<tab>
turns into
Code:
"("()%!^&;, .bat"
Second, when the completion mechanism does do something reasonable, it doesn't double the '%' (shouldn't it?) making the result useless as a parameter to an internal or external command. For example
Code:
"<tab>
turns into
Code:
"()%!^&;, .bat"
which looks OK but needs the '%' doubled before it can be used as a parameter.
 
May 20, 2008
9,431
63
Syracuse, NY, USA
There is an option, under Command Line / Filename Completion, to double percent signs in filenames. (I don't know why it isn't on by default.)
That only works when the first token on the command line is an internal command. I don't get it. What's the difference ... I want to execute it ... I want to COPY it ... I want to NOTEPAD it. The '%' is only doubled in one of those three scenarios; the other two won't work.
 
Last edited:

rconn

Administrator
Staff member
May 14, 2008
11,013
98
My personal feeling is that people who put %'s in their filenames deserve to suffer.

In my professional role, I'll point out that CMD completes those filenames with a single %, The problem with doubling them generically (other than the basic incompatibility) is that TCC has no idea how the expanded filename is going to be processed further or used. (Some commands do not expand variables, some do.) What you want would require yet another full parser running in the tab completion code to analyze the line before expanding the filename.

Regarding the leading ( - note that CMD behaves the same way as TCC. Unless you're asking for the elimination of command groups, it's going to be difficult for TCC to automatically assume that if you have a filename beginning with ( in your current directory, you'll never want to use a command group.
 
May 20, 2008
9,431
63
Syracuse, NY, USA
In my professional role, I'll point out that CMD completes those filenames with a single %, The problem with doubling them generically (other than the basic incompatibility) is that TCC has no idea how the expanded filename is going to be processed further or used. (Some commands do not expand variables, some do.) What you want would require yet another full parser running in the tab completion code to analyze the line before expanding the filename.
I don't see the wisdom in that. We're talking about file name completion, so it's a pretty good bet that the user intends to put a file name in the command (as opposed to some arbitrary string which may/may not contain embedded references to variables). If it's the first token in a TCC command, I would suppose the user wants TCC to execute it. That requires that the % be doubled. And if it's an argument to an external, shouldn't the external get the actual file name? TCC won't give the external the actual file name if completion doesn't double the %.

Code:
v:\> u:\EchoArgs.exe "abc%def.txt"
argv[0]: u:\EchoArgs.exe
argv[1]: abc.txt

v:\> u:\EchoArgs.exe "abc%%def.txt"
argv[0]: u:\EchoArgs.exe
argv[1]: abc%def.txt