top | item 24964589

(no title)

strags | 5 years ago

The problem with shebangs that I really want to solve is that I often need to edit files on a Windows machine, and then try to run the resulting CR/LF scripts on a Linux machine using a shared filesystem. (Docker, WSL, Vagrant etc...).

I'd like to invoke them with just (eg.) ./dostuff.py - Python, Ruby etc... have absolutely no problem running files containing Win-style line-endings. The only issue is that /usr/bin/env complains that it can't find (eg.) "python3\n".

Yes, I know I could convert these files with dos2unix, and I also know that I can just invoke the interpreter explicitly - but I'm lazy, and this seems like such a trivial thing to solve that I can't believe it's not been done already.

I've taken to actually recompiling /usr/bin/env to strip trailing whitespace from the executable name - but there must be a better solution.

discuss

order

AnonC|5 years ago

There are editors that allow preserving the line endings (be they LF, CRLF or CR) from the source file. That could be a solution since you already seem to have control over your environments.

strags|5 years ago

Yeah, this is absolutely true, but we don't really like to impose a rule regarding which editor(s) people use. Most of our workflow is Windows-based.