Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-08-24
04:20 • Add attachment 432499.diff to ticket [432499ffff] artifact: d88096bed7 user: andreas_kupries
04:20 • Ticket [432499ffff] command string passed to exec not quoted status still Cl... artifact: 4116060fac user: andreas_kupries
04:20 • Closed ticket [432499ffff]. artifact: b5431856c3 user: andreas_kupries
03:00 • Ticket [432499ffff]: 4 changes artifact: 49bcf37ad0 user: andreas_kupries
02:58 • Ticket [432499ffff]: 4 changes artifact: a45e52e271 user: kenpoole
02:47 • Ticket [432499ffff]: 4 changes artifact: 85cb536e41 user: andreas_kupries
02:37 • Add attachment demo432499.tcl to ticket [432499ffff] artifact: faef4bed2f user: andreas_kupries
02:37 • Ticket [432499ffff] command string passed to exec not quoted status still Op... artifact: 8340fca71d user: andreas_kupries
2001-08-23
21:19
2001-08-23 Andreas Kupries <[email protected]> * win/tclWinPipe.c (BuildComma... check-in: 34a2db7086 user: andreas_kupries tags: core-8-3-1-branch
21:15
2001-08-23 Andreas Kupries <[email protected]> * win/tclWinPipe.c (BuildComma... check-in: 7c95358bea user: andreas_kupries tags: trunk
05:54 • Ticket [432499ffff] command string passed to exec not quoted status still Op... artifact: c6ced8b2e8 user: andreas_kupries
2001-06-13
15:23 • Ticket [432499ffff]: 1 change artifact: d48228def5 user: dkf
2001-06-12
18:47 • New ticket [432499ffff]. artifact: 7874fefd2a user: kenpoole

command string passed to exec not quoted

Closed / Fixed432499ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-06-12 18:47:30
If I pass the fully qualified path to an executable that has spaces in its path to the exec command, it will execute properly.  If I pass just the command name, it will error out with "invalid argument" as the error message.  

If I modify the source in tclWinPipe.c (starting at line 1525 from the packaged 8.3.3 tar ball) as follows:

#define KEP_EXEC_PROBLEM
#ifdef KEP_EXEC_PROBLEM
if (arg[0] == '\0') {
#else
if (argv[i][0] == '\0') {
#endif
    quote = 1;
} else {
#ifdef KEP_EXEC_PROBLEM
    for (start = arg; *start != '\0'; start++) {
#else
    for (start = argv[i]; *start != '\0'; start++) {
#endif

the exec works as I expect.  The second set of changes is what actually fixes my problem (start=arg).  If the fully qualified path is specified, the argv[0] and arg contain identical strings.  if invoked as:
exec application
the var argv[0] will contain "application", arg will contain the fully qualified path (ie c:\Program Files\appdir\application.exe).  Since the code that checks for "quoting" was looking at argv[0], it wasnt seeing the "space" in the fully qualified path and the command to actually launch the app would fail.
dkf Ticket [432499ffff]: 1 change [History diff]2001-06-13 15:23:12
andreas_kupries Ticket [432499ffff]: 1 change [History diff]2001-08-23 05:54:34
andreas_kupriesplain2001-08-24 02:37:46
File Added - 9907: demo432499.tcl

Logged In: YES 
user_id=75003

The above description is a bit confusing.

Does the problem occur when KEP_EXEC_PROBLEM
is defined or when it is not defined ?

What would be a nice example application I could use ?
(Something which is hopefully everywhere where we have
Windows)

Attaching a demo script which uses our local 'perforce'
client (p4.exe) as the application to run.
_______________________________________
>> I cannot verify the problem <<

What is your operating system ?

I use WinNT 5 and tried to verify this problem for tcl8.4a3
I will try 8.3.3 now too.
andreas_kupriesplain2001-08-24 02:47:31
Logged In: YES 
user_id=75003

I am unable to verify this for 8.3.3 as well,
using Windows NT 5.
kenpooleplain2001-08-24 02:58:23
Logged In: YES 
user_id=68713

The problem occurs when KEP_EXEC_PROBLEM is not defined. 
Sorry about not being clearer ...  as to a sample program to
run, I dont see anything that would be "on all windows
systems" ... it needs to be an application which has a space
somewhere in its path (like any application in "c:\Program
Files\...") that is also in the "PATH" enviroment variable
such that in a "dos" window (cmd.exe on nt) it can be run by
just typing the program name (without typing the absolute
path).  It (unfortunatly) seems to be machine specific ... I
have two machines that show the problem here (both NT5), and
some people around me dont see the problem ... I also sent
the "modified" tcl83 exe to another of our sites since they
were showing the same problem ... I dont know what the
"differing" factor is between these boxes are ... 

What I do know is that when I modified the function
BuildCommandLine to include the argument "executable" in the
check for quoting (which is the affect of the above code
change), then the "executable" string is quoted and the
application executes as expected ...
andreas_kupriesplain2001-08-24 03:00:32
Logged In: YES 
user_id=75003

Looking deeper I see the same difference between 'arg' 
and 'argv [i]' in the case of 'exec app' without full
path. But it doesn't seem to matter anymore to the OS.
andreas_kupriesplain2001-08-24 04:20:44
Logged In: YES 
user_id=75003

Patch accepted. It looks good (other parts of the
code use 'arg' instead of 'argv[i]') and does not
introduce new errors.

Attaching final patch.
Committed this patch to both core-8-3-1-branch (8.3.3)
and the HEAD.
andreas_kupriesplain2001-08-24 04:20:45
File Added - 9912: 432499.diff
Log in (anonymous is fine) to add a comment.

Attachments: