From: "Lawrence Velázquez" <larryv@zsh.org>
To: zsh-users@zsh.org
Subject: Re: piping surprise
Date: Sun, 07 Apr 2024 02:34:47 -0400 [thread overview]
Message-ID: <4d3a1ac0-ae36-4e66-b4f3-56a5d6323b38@app.fastmail.com> (raw)
In-Reply-To: <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
prev parent reply other threads:[~2024-04-07 6:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 13:17 Ray Andrews
2024-04-03 15:00 ` Mikael Magnusson
2024-04-03 15:49 ` Ray Andrews
2024-04-05 20:32 ` Bart Schaefer
2024-04-05 23:11 ` Ray Andrews
2024-04-07 6:34 ` Lawrence Velázquez [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4d3a1ac0-ae36-4e66-b4f3-56a5d6323b38@app.fastmail.com \
--to=larryv@zsh.org \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).