Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: piping surprise
- X-seq: zsh-users 29781
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: piping surprise
- Date: Sun, 07 Apr 2024 02:34:47 -0400
- Archived-at: <https://zsh.org/users/29781>
- Feedback-id: iaa214773:Fastmail
- In-reply-to: <CAH+w=7bVTMo3+qQBMSF0mL1rneoFDuVh_-w-ToCsnmW8gZQW=w@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <a35f798c-0e1e-49cc-89d1-98c28d62bdfb@eastlink.ca> <CAHYJk3QPg-nA=-6HOtBTvYSqjB+AocYWmOkFna61CG_hPDxwUw@mail.gmail.com> <f53e52b4-baed-427f-b2bd-8f72a0553934@eastlink.ca> <CAH+w=7bVTMo3+qQBMSF0mL1rneoFDuVh_-w-ToCsnmW8gZQW=w@mail.gmail.com>
On Fri, Apr 5, 2024, at 4:32 PM, Bart Schaefer wrote:
> However, there's a bug (?) in that if you chain together several
> commands this way, only the first $((++Pnum)) actually increments the
> parameter, so all the commands end up with the same file names. E.g.
>
> echo foo | tr a-z A-Z | cat
>
> just prints "foo".
And sometimes the parameter is not incremented at all:
% (echo foo) | tr a-z A-Z | cat
zsh: no such file or directory: /tmp/zshpipe39158.0
zsh: no such file or directory: /tmp/zshpipe39158.0
% cat <<<foo | tr a-z A-Z | cat
zsh: no such file or directory: /tmp/zshpipe39158.0
zsh: no such file or directory: /tmp/zshpipe39158.0
% typeset -p Pnum
typeset -i Pnum=0
But:
% echo foo | { tr a-z A-Z } | cat
FOO
% typeset -p Pnum
typeset -i Pnum=2
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author