I enabled pipefail in my script for improved safety, but now there is one line that causes the script to fail, even though it's working as intended.
It's this line setting the value of rand_string:
Code:
$ set -o pipefail
$ rand_string=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 12)
$ echo $?
# 141
I assume it's either the cat or tr command that's exiting with code 141. Which one is it? Why is it doing that? How can I make it stop?