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

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



Bart Schaefer wrote:
> 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

That is a good word...

> the way the builtin echo is run in the
> current shell scope.

It has nothing to do with echo being a built-in.  You get the same
result with:

/bin/echo hello | /bin/echo $(/bin/cat)

or, the real reason this came up:

dpkg -S /usr/bin/nedit|dpkg -l $(cut -f1 -d':')

which does not work in zsh for the same reason.

> Consider that these variants do what you expect:
> 
>   echo hello | { echo $(cat) }
>   echo hello | while echo $(cat); do break; done

True.  That really doesn't do much to address my question, though, which
is whether zsh is complying with POSIX here.

Matt Flaschen



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