Bash is frequently used in our build, CI and deployment systems. Some general guidelines and recommended reading
Reading from a file
mapfile instead of
while IFS to read a file
mapfile -t myArray < file.txt
mapfile -t myArray < <(find -d .)
input="/path/to/txt/file" while IFS= read -r line do echo "$line" done < "$input"
Set -eu -o pipefail
This is generally "bash strict mode" and sets
eexit if error
uerror on variable unset (and exit)
-o pipefailfail if items in the pipe | fail. Bash otherwise continues if error | pass which causes some unexpected behavior.
Recommend using these at the start of all scripts and specifically disabling if a section of a bash script does not need them (for example, you want to let a pipe fail).
Utilities in use
shellcheck for our shell script linters