Subject: Re: how to exec command with the char '|' - DN [1]


Alexandre Ferrieux <alexandre.ferrieux@cnet.francetelecom.fr> - 27 Jan 2000 - comp.lang.tcl

 Cameron Laird wrote:
 >
 > In article <388F4CEA.9B66F86D@sdai.com>, Victor Ma  <victor@sdai.com> wrote:
 >                         .
 >                         .
 >                         .
 > >I have been writing tcl on solaris for awhile now.  I would like to call another
 > >execuatable with '|' as an argument.  In tcsh, I have not problem by using
 >                         .
 >                         .
 >                         .
 > You can't.  It's impossible.  No can do.
 >
 > That might surprise you.  I know it disappointed me.
 > It's true, though, to the best of my knowledge.

 You're right in that the flat [exec] doesn't have an escaping character
 for "|" (BTW I think it was a good decision, because giving special
 meaning to (eg) "\" in that situation would have lead to useless pain in
 the 99.99% cases that would never ever ever encounter "|" by itself...)

 However, there's an easy workaround use an extra layer of Shell:

     exec sh -c {echo \|}

 One additional benefit is that the same extra layer is also useful to
 fix little problems with the exit status like in

     exec sh -c {pipeline|of|children|with|random|exit|status;exit 0}

 -Alex

Last modified
2000-02-10

(195.108.246.50)

Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated