Remix.run Logo
aidenn0 2 days ago

What are your thoughts on pipefail in bash? I know ysh (and maybe osh too?) are smart about a -13 result from a pipe, but I stopped using pipefail since the return value can be based on a race, causing things to randomly not work at some point in the future.

[edit]

Per the link you posted osh treats a -13 result as success with sigpipe_status_ok, but I'm still interested in your thoughts on if pipefail is better or worse to recommend as "always on" for bash.

chubot 2 days ago | parent [-]

All my scripts use pipefail, and I haven't run into problems

I think `head` tends to cause SIGPIPE in practice, and that is what sigpipe_status_ok is for

but I stopped using pipefail since the return value can be based on a race, causing things to randomly not work at some point in the future.

Hm I'd be interested in an example of this

The order that processes in a pipeline finish is non-deterministic, but that should NOT affect the status, with either pipefail or not.

That is, the status should be deterministic ... it's possible that SIGPIPE is an exception to that, though that wouldn't affect YSH.