Tcl Source Code

View Ticket
Login
Ticket UUID: 1862356
Title: arguments to TclCreatePipeline cannot start with '|'
Type: Bug Created on: 2008-01-02 18:42:46
Submitter: demillar Assigned to: andreas_kupries
Subsystem: 25. Channel System Severity:
Priority: 5 Medium Last modified: 2026-10-17 07:04:13
Status: Open Closed by:
Resolution: None Closed on:
Version: 8.6.18, 9.0.5, 9.1.0
Description:
Any parameter to TclCreatePipeline which begins with a pipe symbol triggers the 'command needed' case, even if it's not just a | or |&.  This makes it impossible to pass any parameter to a child process which begins with a pipe symbol.

The problem occurs on 8.4.13 but not on 8.4.7.  I haven't checked other versions.

Example:

(Tcl 8.4.7)
% exec echo |foo
|foo

(Tcl 8.4.13)
% exec echo |foo
illegal use of | or |& in command
User Comments:
[email protected] added on 2008-01-04 01:04:05:
Logged In: NO 

works if you separate the "|" from foo
% exec echo | foo

or

% exec echo |& foo

(8.4.14)

dkf added on 2008-01-04 05:18:09:
Logged In: YES 
user_id=79902
Originator: NO

Depends on what you mean "works".

Suggested workaround: I find that when things get tricky, it's better to do this:
  exec sh -c {echo '|foo'}
And when I started using that trick for things exposed to users, my users got happier too; they prefer Unix shell syntax to Tcl's [exec] syntax. On windows, you can do something similar, possibly with the help of a batch script.

serhiy.storchaka added on 2026-10-17 07:04:13:

Regression since 8.4.13 from [47d7a23bdf] (the fix for [768659]): the first pass of TclCreatePipeline() takes any word starting with "|" for a bar, although only "|" and "|&" are, so [exec echo |foo] fails with "illegal use of | or |& in command". Proposed fix in branch exec-pipeline-words, tests exec-23.2 and exec-23.3. It also fixes [2339907fff].