Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-02-03
01:11 • Ticket [672938ffff] Bad exec behaviour at Tcl 8.4.1 status still Closed with... artifact: 1dd6cf35fe user: dgp
2004-02-01
18:27 • Ticket [672938ffff]: 4 changes artifact: 7a96073f49 user: davygrvy
16:29 • Closed ticket [672938ffff]. artifact: 2104f7d927 user: davygrvy
2004-01-29
04:28 • Ticket [672938ffff]: 4 changes artifact: 8e0c914d79 user: davygrvy
04:28 • Ticket [672938ffff]: 4 changes artifact: fbf8762912 user: davygrvy
04:28 • Add attachment patch.txt to ticket [672938ffff] artifact: 2185f73161 user: davygrvy
2003-12-16
17:06 • Ticket [672938ffff] Bad exec behaviour at Tcl 8.4.1 status still Open with 4... artifact: 16bbbc53ac user: davygrvy
2003-05-11
07:15 • Ticket [672938ffff]: 1 change artifact: a7a5a84d3d user: hobbs
2003-01-24
22:34 • Ticket [672938ffff]: 4 changes artifact: dc1d3a909f user: softmick
15:41 • Ticket [672938ffff]: 4 changes artifact: 2723cd567a user: vincentdarley
14:36 • Ticket [672938ffff]: 4 changes artifact: fd43e78c3a user: softmick
06:29 • Ticket [672938ffff]: 4 changes artifact: c38d4aa983 user: davygrvy
06:25 • Ticket [672938ffff]: 4 changes artifact: e69bd64e35 user: davygrvy
06:12 • Ticket [672938ffff]: 4 changes artifact: fd67fc4e06 user: davygrvy
06:07 • Ticket [672938ffff]: 4 changes artifact: 8257b3a5a2 user: softmick
05:33 • Ticket [672938ffff]: 4 changes artifact: baddcd66df user: davygrvy
05:30 • Ticket [672938ffff]: 4 changes artifact: 067a80adb3 user: davygrvy
04:51 • Ticket [672938ffff]: 4 changes artifact: e91dfdc805 user: davygrvy
04:40 • Ticket [672938ffff]: 4 changes artifact: b87a1917af user: dgp
00:26 • Ticket [672938ffff]: 4 changes artifact: 5106a66620 user: softmick
2003-01-23
16:28 • Ticket [672938ffff]: 2 changes artifact: c921894926 user: dkf
06:53 • New ticket [672938ffff]. artifact: cdb735fd18 user: nobody

Bad exec behaviour at Tcl 8.4.1

Closed / Fixed672938ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 23 years ago
Descriptionplain2003-01-23 06:53:35
At Tcl 8.3
% exec echo [list 1 2 "3 and 4"]
1 2 {3 and 4}

This looks correct to me

At Tcl 8.4
% exec echo [list 1 2 "3 and 4"]
1 2 \{3 and 4}

Note the extra back-slash at 8.4 which looks wrong to 
me.

I am running on Windows (98) with version 
ActiveTcl8.4.1.0-2-win32-ix86.exe

[email protected]
dkf Ticket [672938ffff]: 2 changes [History diff]2003-01-23 16:28:12
softmickplain2003-01-24 00:26:28
Logged In: YES 
user_id=695046

I am advised that this problem (new at 8.4) could be a consequence of fixing a previous exec bug:

554068
dgpplain2003-01-24 04:40:59
Logged In: YES 
user_id=80530

Just curious whether this bug an Bug 554608
were reported for the same release of Windows?
davygrvyplain2003-01-24 04:51:12
Logged In: YES 
user_id=7549

That behavior can be removed by taking out the part where 
that is quoted.

diff -c -r1.32 tclWinPipe.c
*** tclWinPipe.c17 Dec 2002 02:47:39 -00001.32
--- tclWinPipe.c23 Jan 2003 21:43:15 -0000
***************
*** 1594,1604 ****
  Tcl_DStringAppend(&ds, "\\\"", 2);
  start = special + 1;
      }
!     if (*special == '{') {
  Tcl_DStringAppend(&ds, start, special -
 start);
  Tcl_DStringAppend(&ds, "\\{", 2);
  start = special + 1;
!     }
      if (*special == '\0') {
  break;
      }
--- 1594,1604 ----
  Tcl_DStringAppend(&ds, "\\\"", 2);
  start = special + 1;
      }
! /*    if (*special == '{') {
  Tcl_DStringAppend(&ds, start, special -
 start);
  Tcl_DStringAppend(&ds, "\\{", 2);
  start = special + 1;
!     }*/
      if (*special == '\0') {
  break;
      }

What's interesting is that this is now showing itself.  There 
are a set of rules this quoting mechanism needs to do so 
args can be pulled back out of the single string and placed in 
an argv array by the process that this line is handed.
davygrvyplain2003-01-24 05:30:28
Logged In: YES 
user_id=7549

There is a double-quote problem in the current behavior of 
BuildCommandLine().  Somehow this was recently broken.

if the commandline is this to CreateProcess():
a.exe b c=""d""

_SHOULD_ expand to an argv array of
argv[0] = a.exe
argv[1] = b
argv[2] = c="d"

if the commandline is this to CreateProcess():
a.exe b "c = d"

_SHOULD_ expand to an argv array of
argv[0] = a.exe
argv[1] = b
argv[2] = c = d

GetCommandLine()->argv processing is done by the C-
runtime of the process launched.  It is out of Tcl's control.  If 
some processes follow the quoting rules and others do not...  
then we're fighting a losing battle.
davygrvyplain2003-01-24 05:33:58
Logged In: YES 
user_id=7549

% exec $env(COMSPEC) /c echo asd a="b"
asd a=\"b\"

The above should NOT be doing what you see.  
BuildCommandLine() MUST turn those quotes into two and 
NOT place a backslash in front of it.
softmickplain2003-01-24 06:07:22
Logged In: YES 
user_id=695046

I do not quite understand the comments here, but I wonder 
if it is helpful to add thaat if I call a second Tcl script from a 
first script with arguments the problem is apparent. That 
is, the second script will get aruments with extra back-
slash characters in it:
e.g. 
exec wish printargs.tcl -- {3 and 4}
So Tcl/Tk is not internally consistent. 
I hope this helps. Mick
davygrvyplain2003-01-24 06:12:38
Logged In: YES 
user_id=7549

Yes, Tcl must be internally consistent, but it must go 
EXTERNAL to do it according to the quoting rules that the C-
runtime uses.

The rules for turning a commandline string into a vector is 
contained by parse_cmdline() found in the MS runtime 
src\crt\stdargv.c

BuildCommandLine in tclWinPipe.c must be the inverse of 
the runtime's parse_cmdline().  This is the problem here.
davygrvyplain2003-01-24 06:25:12
Logged In: YES 
user_id=7549

The problem is compounded by the fact that tclsh (in 
win/tclAppInit.c) uses a custom argv setting routine that is 
not the default of the runtime.

We may fix Tcl to itself, but then calls to others apps will not 
be correct which tends to show itself when launching cygwin 
utilities which probably use a whole different rule set anyways.
davygrvyplain2003-01-24 06:29:55
Logged In: YES 
user_id=7549

Ok, first job is to make BuildCommandLine() exportable to 
the private Stubs table so I can put it in a test suite.

Then we can compare it against the runtime's parse_cmdline
() and against the custom one of win/tclAppInit.c and get this 
matter squashed.
softmickplain2003-01-24 14:36:26
Logged In: YES 
user_id=695046

David

The Tcl/Tk community is so very helpful. Thank you so much 
for looking at my problem with such enthusiasm and skill! I 
hopebody minds me putting this personal comment here for 
the record.

Mick
vincentdarleyplain2003-01-24 15:41:01
Logged In: YES 
user_id=32170

As dgp asked, the original problem was on Win2000. I don't know if 
behaviour is different across different Win systems.  Also, as Dave 
points out, cygwin may do something completely different -- if so, then 
cygwin is at fault, I think -- we should fix for the standard Win shell.

Anyway, I'm happy to test any proposed fixes, and we obviously need to 
add appropriate tests to the test suite as well.
softmickplain2003-01-24 22:34:21
Logged In: YES 
user_id=695046

When I found the problem, I was sending arguments from one Tcl/Tk script to another. In trying to understand the 
problem, I simplified it to running echo (from cygwin) from the wish shell by hand. It looks to me like cygwin reads 
the arguments exactly the same way the Tcl/Tk does now. I am assuming that the problem is with sending the 
arguments rather than reading them - hence your error going via $env(COMSPEC). Therefore, I am hopeful that 
cygwin interfaces will prove OK.

I am unable to compile, but other than that, I am happy to help test.

[email protected]
hobbs Ticket [672938ffff]: 1 change [History diff]2003-05-11 07:15:09
davygrvyplain2003-12-16 17:06:56
File Added - 70719: patch.txt

Logged In: YES 
user_id=7549

Here's a patch that fixes this.  It needs some more work to 
polish it.
davygrvyplain2004-01-29 04:28:41
File Added - 75040: patch.txt

Logged In: YES 
user_id=7549

Updated patch..  Needs test suite additions or, rather, 
verification with cases.
davygrvyplain2004-01-29 04:28:42
File Deleted - 70719:
davygrvyplain2004-02-01 16:29:12
Logged In: YES 
user_id=7549

Committing fix to HEAD. tclWinPipe.c -r1.41
davygrvyplain2004-02-01 18:27:00
Logged In: YES 
user_id=7549

FYI, no test case existed to show the need for the custom 
setargv() used in both the tcl and wish shells.  Therefore, it 
was removed in favor of the c-runtime's work.
dgpplain2004-02-03 01:11:27
Logged In: YES 
user_id=80530


What does this change
do to Tcl Bug 554068?
Log in (anonymous is fine) to add a comment.

Attachments: