4 ms·
so you call one command and want just to know if it failed... but that command triggered a series of pipes internally, now you have to trim the status mess? th
by gcb 15y ago
so you call one command and want just to know if it failed... but that command triggered a series of pipes internally, now you have to trim the status mess?
thankfully truly posix stuff doesn't have it
- sigil 15y agobut that command triggered a series of pipes internally, now you have to trim the status mess? No. If you run an external command from an rc script, ie the shell is doing the fork and exec for you, then $status will have a single number just like $?. It doesn't matter if the external command is an rc script that, internally, runs a pipeline at the end. You will only get a multi-status if the previous statement within the current rc script was a pipeline. Under sh, bash, or ksh, people rarely bother to look at $? in this situation, since it's either potentially irrelevant (without -o pipefail), or you don't know which program it's from (with -o pipefail). so you call one command and want just to know if it failed This works perfectly fine in rc: find . | grep '[0-9]' | wc || echo >[1=2] "number files not found" From the rc docs: > Any $status containing only 0’s and |’s has boolean value true. Any other status is false.