Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Pipeline question (echo hello | echo $(cat))



On Sun, Jan 18, 2009 at 12:17 PM, Matthew Flaschen
<matthew.flaschen@xxxxxxxxxx> wrote:
>
> echo hello | echo $(cat)
>
> cat: -: Input/output error

Hmm.

I'm not sure this is precisely an order-of-execution thing; rather, I
think zsh over-optimizes the way the builtin echo is run in the
current shell scope.  Consider that these variants do what you expect:

  echo hello | { echo $(cat) }
  echo hello | while echo $(cat); do break; done

The command in braces and the "while" are also run in the current
shell scope, but don't suffer from the i/o error.  You can see this
with e.g.:

  echo hello | { echo $(cat); SCOPE=current }; echo $SCOPE



Messages sorted by: Reverse Date, Date, Thread, Author