exec $env(COMSPEC) /c $file
Tends to work just fine, unless the value of $file (i.e. the name of the
file I'm tring to open) has a set of parenthesis in it. No matter what I
do, I'm unable to properly escape the value passed to exec. I believe
I've gone through every combination of curly braces, quotes, escapes,
and multiple escapes. Anyone else seen this?
-CN
Okay, so I've done a bit more looking into this and discovered that
the issue I'm having is 1/2 due to Windows and 1/2 due to Tcl. In
order to open a file whose name contains () with cmd.exe from a
regular Windows command prompt, one does this:
C:\Temp>cmd /c ""new(1).gif""
C:\Temp>
Because if you're using special characters with '/c'... "old behavior
is to see if the first character is a quote character and if so, strip
the leading character and remove the last quote character on the
command line, preserving any text after the last quote character."
So the first and last quotes are stripped, preserving a useful set of
quotes that escapes the parenthesis. Windows oddness sure, but I'll
deal with it (unless someone cares to tell me that I'm way off base
doing it this way). Of course, trying this all with Tcl yeilds
slightly different results...
% exec $env(COMSPEC) /c {""new(1).gif""}
The filename, directory name, or volume label syntax is incorrect.
%
Okay, slip an echo in there to see if everthing is working properly,
and...
% exec $env(COMSPEC) /c echo {""new(1).gif""}
\"\"new(1).gif\"\"
%
Suddenly there are *escaped* quotes being passed. Am I wrong, or is
TCL auto-escaping my quotes (because of the curly braces?)? How do I
pass unescaped quotes through exec?
I'm currently using Win2k and Tcl 8.4.5
-CN
set winname [file nativename new(1).gif]
to get an alias name that does not require all those messy quotation
marks?
Brian