Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG] Pipe fails even when using ' || true '
- X-seq: zsh-workers 48247
- From: Rudi C <rudiwillalwaysloveyou@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [BUG] Pipe fails even when using ' || true '
- Date: Fri, 26 Mar 2021 17:23:08 +0430
- Archived-at: <https://zsh.org/workers/48247>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-03/CAE9z9A2QMgmPA%2ByUjuVf_CkioEDhb2oYQhsROuNpakUHgrpkxQ%40mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
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:
...
```
Messages sorted by:
Reverse Date,
Date,
Thread,
Author