Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[Fixed Hardwrap][BUG] Pipe fails even when using ' || true '



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



Messages sorted by: Reverse Date, Date, Thread, Author