[–] vlisivka 17y ago ↗ Use "set -u" to treat unset variables as an error when substituting. Use "||" operator to handle errors. My pattern:an_command || { error "Cannot execute an_command. Exit code: $?." return 1 }Always wrap variables with double quotes, unless you really need to parse variable value by bash. Use arrays, when you need to pass multiple arguments. And so on.
1 comment
[ 0.24 ms ] story [ 8.2 ms ] threadan_command || { error "Cannot execute an_command. Exit code: $?." return 1 }
Always wrap variables with double quotes, unless you really need to parse variable value by bash. Use arrays, when you need to pass multiple arguments. And so on.