Specific suggestions:
- Function names are by convention
snake_case. - Use More Quotes™.
[[should be used instead of[, because it's safer.- Use
[[ -e PATH ]]to check for the existence of a path. So[ -z "$(ls -A ../logs_and_inputs)" ]should be! [[ -e ../logs_and_inputs ]].lsis not suitable for scripts (1, 2). [[ EXPRESSION ]] && [[ EXPRESSION ]]would be clearer than[[ EXPRESSION && EXPRESSION ]], in my opinion.set -o errexit -o noclobber -o nounset -o pipefailandshopt -s globfailwould make the error handling much stricter.- This is no longer trivial code, so I'd recommend implementing it in a non-shell language like Python.
Tool suggestions:
- Running
shellcheckon your script regularly is a good way to capture possible issues. In this case the only thing it finds is forrm -r *x*x*:SC2035: Use ./glob or -- glob so names with dashes won't become options.