On Mon, Mar 9, 2026 at 11:24 AM Stan Marsh <[email protected]> wrote:
>
> There *are* scripting languages that read in the entire
> source at startup and build an internal representation which is then
> executed. These languages then don't care if you mess with the source
> while the script is running.
Keep in mind, if you want this behavior, it's not hard to get.
You can literally just enclose your existing bash script between a
pair of curly braces to force bash to parse the whole thing before it
starts to run it.
Any script I write with any function ends up looking like this:
set # options
shopt # options
unset CDPATH TMOUT
# readonly global variables
main () {
# do things
exit 0
}
func1 () {
# do things
}
func2 () {
# do things
}
main "${@}"
Because the call to main () is the last bit of code in the script,
everything has been parsed before it runs there too.