Why is my bash script trying to run comments as code?
bash, python
Solution
I found the problem! I was editing the bash script while it was running, this is what caused the crashes.
Problem
I am writing a bash script to run several python programs in a particular order and it looks like this: ``` #!/bin/bash set -e python prog1.py #make database python prog2.py #plots python prog3.py #more plots ``` This runs fine, but when I comment out the first line: ``` #!/bin/bash set -e #python prog1.py #make database python prog2.py #plots python prog3.py #more plots ``` It crashes with: ``` ./python_progs.sh: line 3: plots: command not found ``` It is as if it is ignoring the '#' in front of 'plots' and is trying to run it as code. Another strange thing is this does not happen all the time, sometimes the second code runs with no problems, sometimes it crashes. Am I missing something basic about how commenting works in bash scripts? For the people commenting below here is the exact code: ``` #!/bin/bash set -e python footprint_hex.py >> ./paper/qso_num.txt #this makes the footpring figures python sed_db_read.py #makes the inital databases python sed_db_read2.py #makes the new databases for lum and civ and modles python sed_db_plots_paper.py #plots python sed_db_plots_paper_png.py #plots ``` When no lines are commented it works fine but when commenting out lines 3 and 4 it crashes with: ``` ./compile_dbs.sh: line 5: and: command not found ``` and when commenting out lines 3, 4, and 5 it crashes with : ``` ./compile_dbs.sh: line 6: plots: command not found ``` My exact steps for running the script are: ``` ./compile_dbs.sh ```