This is not necessarily the current version of this TIP.
| TIP: | 202 |
| Title: | Add 2>@1 Special Case to [open] and [exec] |
| Version: | $Revision: 1.1 $ |
| Author: | Jeff Hobbs <jeffh at activestate dot com> |
| State: | Draft |
| Type: | Project |
| Tcl-Version: | 8.5 |
| Vote: | Pending |
| Created: | Wednesday, 19 May 2004 |
| Keywords: | Tcl, redirection |
This TIP proposes adding a new redirection case '2>@1' that redirects the error channel to the output channel in open and exec. This would only be valid at the end of a pipeline.
Tcl is currently limited on how stderr can be managed from a command opened with open | or exec. This TIP adds the ability to simply combine the stderr stream with the stdout stream by adding a new output redirection case, 2>@1 (i.e. as in Bourne shell syntax), that is only ever valid as the last redirection item in a pipeline. This will enable simple capturing of stderr as well as stdout across platforms.
The behavior is similar to 2>@stdout, but that does not work across platforms. The difference is that directs to a real stdout file channel (which is not available in Windows wish for example), whereas 2>@1 would redirect to the output result for exec/open.
The intention is to handle the common case of wanting to capture stderr as well as stdout output from a single command. This operator is only valid as the last redirection operator. To redirect stderr of previous commands along with their stdout, use the preexisting |& pipe operator.
This is backwards compatible as 2>@1 currently raises an error that "1" is not a valid file id (Tcl does not create such file ids).
set fid [open "|$cmd 2>@1"] set result [exec $cmd 2>@1]
See SF Tcl Patch 957132 [1] for details.
This document has been placed in the public domain.
This is not necessarily the current version of this TIP.