Description of Problem: If the first line (at least) of a bash shell script is terminated with the DOS newline, i.e., <CR><LF>, the script will fail to execute, yielding the message "No such file or directory." Although such behavior might be considered "correct", it can be very confusing for the unwary since at least one of the standard editors (vi/vim) doesn't display the <CR> character, nor does the <CR> appear if the script is 'cat' to the terminal. Version-Release number of selected component (if applicable): N/A How Reproducible: Always Steps to Reproduce: 1. Create example script "bashlin": ----------------- #!/bin/bash echo "running script" ----------------- 2. Create similar script "bashdos" with DOS newlines: $ unix2dos -n bashlin bashdos 3. Make both scripts executable: $ chmod 777 bashlin bashdos 4. Attempt to execute both scripts: $ ./bashlin $ ./bashdos Actual Results: Script "bashlin" works as expected. Script "bashdos" fails to execute with the message "No such file or directory". Expected Results: Both scripts ought to execute, or at least provide a more descriptive error message upon failure. Additional Information: Shell tcsh has the same problem.
This is the intended behavior. DOS-style newlines put a \r character before the real newline, so the shell tries to launch appname\r which of course doesn't exist (but might - there's nothing that prevents you from using this character in a filename).