TIP #202: ADD 2>@1 SPECIAL CASE TO [OPEN] AND [EXEC] ====================================================== Version: $Revision: 1.4 $ Author: Jeff Hobbs State: Final Type: Project Tcl-Version: 8.5 Vote: Done Created: Wednesday, 19 May 2004 URL: https://tip.tcl-lang.org202.html Post-History: ------------------------------------------------------------------------- ABSTRACT ========== 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. RATIONALE =========== 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). EXAMPLES ---------- set fid [open "|$cmd 2>@1"] set result [exec $cmd 2>@1] REFERENCE IMPLEMENTATION ========================== See SF Tcl Patch 957132 [] for details. COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows