zsh-workers
 help / color / mirror / code / Atom feed
* [Fixed Hardwrap][BUG] Pipe fails even when using ' || true '
@ 2021-03-26 13:09 Rudi C
  2021-03-26 17:16 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Rudi C @ 2021-03-26 13:09 UTC (permalink / raw)
  To: zsh-workers

[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-27  8:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 13:09 [Fixed Hardwrap][BUG] Pipe fails even when using ' || true ' Rudi C
2021-03-26 17:16 ` Bart Schaefer
2021-03-27  8:30   ` Mikael Magnusson
2021-03-27  8:32     ` Mikael Magnusson

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).