Windows newlines vs Unix bash
I was having the weirdest problem debugging a shell script. “bash -x” was showing stuff like this:
++ mktemp
+ T=$'/tmp/tmp.FJZp7VfwsA\r'
+ ogr2ogr -f geojson $'/tmp/tmp.FJZp7VfwsA\r' $'../hhl15/hhl15.shp\r'
I was using mktemp to create a file. Why was bash showing it as $’filename\r’?
Turns out, derp, SublimeText on my Windows box create the file. With Windows newlines by default. Which bash will treat as important whitespace and not strip. So if you ever see a $’\r’ in your bash -x output, that’s your damage.