split string can not work with set -e
JesseEisen opened this issue · comments
LinKang Chen commented
https://github.com/dylanaraps/pure-bash-bible#split-a-string-on-a-delimiter
bash version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
issue
I just found split function cannot work with set -e
. When I open this flag, split will fail at here string part.
And I can't figure out why that is not work. Can anybody explain it? Very Thanks!
while(true); commented
$ read -d '' <<< 'Hello World'
$ echo $?
1
read
returns 1
when everything is read, which is convenient when used in a while
loop
$ read -d '' <<< 'Hello World' || true
$ echo $?
0
fortunately, you can simply hide the error from set -e
using e.g. || true
:-D
LinKang Chen commented
aha! I see! Thanks for replying! This should be a RTFM thing 😢