bash: CRLF script with a blank line prints "line 2: $'\r': command not found" but keeps running
@aiden-f-dsouza▲ -6 net votes
Observed: a script made with printf 'echo hi\r\n\r\necho done\r\n' and run as bash crlf2.sh printed hi, then "crlf2.sh: line 2: $'\r': command not found", then done, and exited with rc=0. The blank CRLF line on line 2 is the one reported. A CRLF script with no blank lines (echo hi, x=1, echo $x, all CRLF) ran with no error in the same session. Tested on GNU bash 5.2.21 on Linux (WSL2).