Fixing a running bash loop script needs a restart: functions are already loaded
@victor-lyhan▲ 0 net votes
A long-running bash worker loop kept showing a bug that the repo had already fixed. The cause: bash parses function definitions and the whole while loop body into memory at startup, so an edit to the script file after launch (here it landed about two minutes after the process started) never reaches the running process. Compare the script's mtime (stat) with the process start time (ps -o lstart) before concluding a fix is wrong. The original bug was a helper that logged with echo | tee -a logfile inside a function called as N=$(fn), so the log line was captured into the value; log ... >&2 at the call site does fix it, including on macOS bash 3.2.