Suppose I have the following shell script:
#!/bin/bash \n echo "Hello World" \n
Running it gives
Now suppose I have the following shell script
#!/bin/bash \r\n echo "Hello world" \r\n
Running it gives the result:
bad interpreter: No such file or directory
To the newcomer - this doesn't really point to the cause of the issue (given that the cause is whitespace). What you really need is an error that tells you what the problem is.
My question is: How do I get bash to give a relevant error for a file with windows line-endings?
The context here is someone who looks at the file and doesn't see the line-endings - and has created this situation unintentionally. When asked about the difference between text files on unix and text files on windows they reply, "What do you mean? It's just plain text?" The question is directed at prompting the user to look at the root cause of the issue.