For convenience, I sometimes keep all execution commands within a single bash file and run them according to my applications. Let's say I have a bash script exec.sh
as shown below.
python a.py
#python b.py
I notice that sometimes when I run exec.sh
to execute python a.py
and modify the script before the previous execution finishes:
#python a.py
python b.py
the first execution will continue to run python b.py
, even after finishing python a.py
.
My question is: why does it continue?
I suppose the first execution only see this. It seems unreasonable to me that the program will runs a comment.
python a.py
#python b.py
My suspection is that the bash interpreter works line-by-line, so at the begining it only sees python a.py
, but when it finishes, it will read again the file and see python b.py
being available.
The operating system is Ubuntu 22.04.1 LTS with a bash version 5.1.16(1)-release (x86_64-pc-linux-gnu).
I will appreciate any thoughts or any possible reasons that cause this situation.
thanks.