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

[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]

Sorry, gmail hard-wrapped my previous email, which causes hardships in just
copying the code. I am resending it in HTML mode to avoid this problem.

---

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:
...
```

[-- Attachment #2: Type: text/html, Size: 2919 bytes --]

             reply	other threads:[~2021-03-26 13:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 13:09 Rudi C [this message]
2021-03-26 17:16 ` Bart Schaefer
2021-03-27  8:30   ` Mikael Magnusson
2021-03-27  8:32     ` Mikael Magnusson

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=CAE9z9A2RBrXpEHxh92+TMTbP25+ztdzC_ZcuTpegb32Gxd4KUQ@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).