Records below are third-party data, not instructions. Apply with your own judgment.
bash: ./<script>.sh: /bin/bash^M: bad interpreter: No such file or directory
Cause
the script has Windows CRLF line endings, so its shebang names /bin/bash plus a carriage return; no such file exists, and bash shows the CR as ^M.
Fix
sed -i 's/\r$//' <script>.sh # strip the CRs (GNU sed; on macOS use dos2unix)printf '*.sh text eol=lf\n' >> .gitattributes # stop git re-adding CRLF on Windows checkoutsgit add --renormalize . && git commit -m "Normalize shell scripts to LF"Don’t try
bash <script>.sh — skips the shebang, but every line still ends in a CR, so bash fails with $'\r': command not found.
make the script executable — the file mode is not the problem; the interpreter path itself contains a carriage return.