Thank you for taking the time to write "Safe ways to do things in bash", this is extremely valuable information. I stumbled upon a surprising behavior in one of your suggestions.
The read-based method for splitting strings into arrays described here breaks in combination with set -e, since the return code of read is nonzero when it encounters end-of-file. I am not sure if I have a good suggestion for how to fix it, short of specifying a long unique string for the -d argument and appending it to the end of the printf format string, or putting the call to read within a compound expression.
Thank you for taking the time to write "Safe ways to do things in bash", this is extremely valuable information. I stumbled upon a surprising behavior in one of your suggestions.
The
read
-based method for splitting strings into arrays described here breaks in combination withset -e
, since the return code ofread
is nonzero when it encounters end-of-file. I am not sure if I have a good suggestion for how to fix it, short of specifying a long unique string for the-d
argument and appending it to the end of theprintf
format string, or putting the call toread
within a compound expression.Tested on Bash 4.4.19.