zsh-workers
 help / color / mirror / code / Atom feed
From: Rudi C <rudiwillalwaysloveyou@gmail.com>
To: zsh-workers@zsh.org
Subject: [BUG] Pipe fails even when using ' || true '
Date: Fri, 26 Mar 2021 17:23:08 +0430	[thread overview]
Message-ID: <CAE9z9A2QMgmPA+yUjuVf_CkioEDhb2oYQhsROuNpakUHgrpkxQ@mail.gmail.com> (raw)

This pipe unexpectedly fails:

```
$ setopt pipefail
$ { print -nr -- "x" || true } | eval 'print -rn --
"${(q+@)brish_stdin}"' ; echo $'\n'Returned
$?:"${(j.|.)pipestatus[@]}"
''
Returned 141:141|0
```

This is the simplest thing I have found that works:
```
$ ( ( print -nr -- "l" ) || true ) | eval 'print -rn --
"${(q+@)brish_stdin}"' ; echo $'\n'Returned
$?:"${(j.|.)pipestatus[@]}"
''
Returned 0:0|0
```

Even this fails:
```
$ ( { print -nr -- "l" } || true ) | eval 'print -rn --
"${(q+@)brish_stdin}"' ; echo $'\n'Returned
$?:"${(j.|.)pipestatus[@]}"
''
Returned 141:141|0
```

The behavior is nondeterministic on macOS, and it actually doesn't
usually fail at all!
```
$ for i in {1..100} ; { { print -nr -- "x" || true } | eval 'print -rn
-- "${(q+@)brish_stdin}"' ;echo $'\n'Returned
$?:"${(j.|.)pipestatus[@]}" }
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 141:141|0
''
Returned 0:0|0
''
Returned 0:0|0
''
Returned 0:0|0
```

BTW, there seems to be another weird thing going on; Adding two spaces
before `echo` breaks the whole loop both on Linux and macOS:

```
for i in {1..100} ; { { print -nr -- "x" || true } | eval 'print -rn
-- "${(q+@)brish_stdin}"' ;  echo $'\n'Returned
$?:"${(j.|.)pipestatus[@]}" }

''zsh: command not found:
''zsh: command not found:
''zsh: command not found:
''zsh: command not found:
...
```


                 reply	other threads:[~2021-03-26 12:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAE9z9A2QMgmPA+yUjuVf_CkioEDhb2oYQhsROuNpakUHgrpkxQ@mail.gmail.com \
    --to=rudiwillalwaysloveyou@gmail.com \
    --cc=zsh-workers@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).