I am using VM (in my case simply boot2docker) to run docker containers on Windows host. For convinience, my source files are mapped from host file system, so text files are by default using Windows-style CRLF line endings instead of Unix-style LF endings.
When I try to run some .sh file from docker container, I'll get an error
bash: ./script.sh: /bin/bash^M: bad interpreter: No such file or directory
Is there a way how could I somehow tell bash/sh interpreter to automatically convert \r\n to \n and run a file?
Sure, I could do some piplelining like this cat script.sh | tr -d "\r" | sh
or even create an alias for that, but it would not cover situation where one script includes another.
The only acceptable solution I have found so far, is to set Git to checkout source files in UNIX format.
echo $TERM
?echo $TERM
returnsdumb
export TERM=xterm
orexec >/dev/tty 2>/dev/tty </dev/tty
(tip from github.com/docker/docker/issues/728)