SETUP:
A large repository is cloned via 'git' where line endings are adapted automatically. That is, a bash script checked in under Linux appears under Windows as a file with endings 0D0A instead of only 0A. The policy of checkout cannot be modified.
Any script checked out under Windows appears with 0D0A as line endings. Scripts 'source' other scripts, so converting one script does not suffice. Converting all scripts in the repository is not practical.
PROBLEM:
Window's bash
does not run on scripts where the line ending is 0D0A. First idea was bash-0d0a
converting before execution:
tmp=$(mktemp)
script=$1
shift
awk 1 RS='\r\n' ORS='\n' $script > $tmp
mv $tmp $script
source $script $@
The adapter 'bash-0d0a', however, does not treat 'source-ed' files from within the file to be treated.
QUESTION:
Would it make sense to do:
export PATH=$(dirname path-to-bash-0d0a):$PATH
mv bash-0d0a bash
Or, is it possible, somehow, to let bash
do this directly?