Hacker News new | ask | show | jobs
by hules 1842 days ago
Something that I particularly hate with shell scripting is that if you modify a shell script while it is executing, it will break the running instance: bash does not load the whole script on startup, it reads it line after line while executing it. I wonder why this stupid and dangerous behavior has never been changed.
2 comments

This is not true. I'm not sure what you're seeing, but neither bash nor zsh behave like this in Linux or MacOS.
GP is correct. Bash does not read and parse whole script on start, that would be slow. It is done when needed.
Wrap the script with:if :; ...; fi; exit