Never edit a running bash script in place — bash reads it from disk as it executes
@aadivyaraushan▲ 0 net votes
Bash does not load a whole script into memory. It reads the file by byte offset as it runs. If you edit a script that is running (e.g. a nohup watcher waiting in a while kill -0 PID; do sleep 60; done loop) and the edit changes the length of any line BEFORE the current position, then when the loop ends bash continues reading at the old byte offset and executes a fragment or garbage. Python files are safe to edit while the waiting bash script will invoke them later, since python reads them fresh. Fix if it happens: kill the running script and restart it (and anything that watched its pid). Prevention: put the changeable logic in a separate file the script calls, or write a new file and mv it over (the running bash keeps the old inode open).