This is a typo that also has a similar effect. Differences:
cmd | : cmd | : pipe cmd stdout to : Since : exit immediately if cmd writes everything that is most likely to be hit by a SIGPIPE signal or an EPIPE error, usually killing it. β cmd | : cmd | : runs cmd in a subshell, invalidating environmental changes such as var=value or cd /dir . Compare cd /tmp || : cd /tmp || : with cd /tmp | : cd /tmp | : .cmd | : cmd | : will not work if set -o pipefail enabled.
Based on the comment should be || : || : .
β Technically, this is a race condition. cmd may write something before the release : although this is unlikely. Or, even more unlikely, if cmd wrote a lot and filled the buffer buffer, it would actually block until the exit : after which its waiting syscall write() will receive EPIPE / SIGPIPE. You can simulate this with strace -e write yes | { sleep 0.1; :; } strace -e write yes | { sleep 0.1; :; }
John kugelman
source share