I know, I know... It's no longer "cool" to develop on Windows. Many developers these days have switched to M1 Mac and not looked back. And to be honest, I don't blame them. Apple's M-series chips are incredibly impressive.
But it has caused developers to forget/get lazy about a critical consideration - line endings!!
Most tools & languages these days have gotten a lot less picky about LF vs CRLF, and will happily compile either. I bet most developers have even forgotten line endings are even a thing!
There's one big holdout, though... bash
/sh
Have you ever checked out a repo on your Windows dev machine, noticed it has a .sh
script file, popped open your WSL distro to run it, and been presented with:
/> ./run.sh
-bash: ./run.sh: /bin/bash^M: bad interpreter: No such file or directory
...or worse yet:
/> ./run.sh
./run.sh: line 1: $'\r': command not found
./run.sh: line 4: $'\r': command not found
This is because the maintainer of that repository got lazy, forgot about, or has simple hatred for, Window users and line endings!! If unspecified, git
will "helpfully" try to check files out in a format that makes sense for the platform. On Windows, the convention is CRLF line endings. Which, as stated before, isn't as big of a deal these days... Except when it is 🙂
So, do your fellow Windows-using comrades a favor...and ADD A .GITATTRIBUTES FILE TO YOUR REPOS - one that at least specifies *.sh
with eol=lf
, and anything else you're aware of that would affect out-of-the-box cross platform functionality.
Sincerely,
-DrEsteban