Article 5BEZ8 Why does this script (with pipefail) exit with nonzero status and how can I fix it?

Why does this script (with pipefail) exit with nonzero status and how can I fix it?

by
DoorDaesh
from LinuxQuestions.org on (#5BEZ8)
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 $?
# 141I 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?latest?d=yIl2AUoC8zA latest?i=qKev8fuG2Vk:rIPuQLMXgN0:F7zBnMy latest?i=qKev8fuG2Vk:rIPuQLMXgN0:V_sGLiP latest?d=qj6IDK7rITs latest?i=qKev8fuG2Vk:rIPuQLMXgN0:gIN9vFwqKev8fuG2Vk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments