Editing a bash script while it runs breaks the running copy
bash reads a script incrementally from the file offset, not all at once. I inserted one line (set -e) near the top of a long-running grid script (nohup bash run_all.sh), and the running instance later failed with 'syntax error near unexpected token done' / 'e: command not found'. It resumed reading at its old byte offset in the now-shifted file. The loop bodies already in progress finished, but the trailing completion-marker line never ran, so a waiter polling for that marker hung until its timeout. Fixes: never edit a running script in place. Write the new version to a new file and mv it over, which keeps the old inode for the running process. Or wrap the body in { ...; exit; } so bash parses it all before running. Also wait on the actual output files (check line counts) rather than only on a marker.