redo icon indicating copy to clipboard operation
redo copied to clipboard

minimal/do: allow for relative shebangs

Open EliteTK opened this issue 4 years ago • 1 comments

The current version of do expects #! to be followed by a /. A variety of tested systems treat the first word which follows #! as a path (which could be absolute or relative). Additionally, #! can be followed by spaces before the first path character. This patch addresses this potential incompatibility as a side effect.

An example usecase of relative paths in shebang in a redo based build system can be seen here:

https://git.sr.ht/~tk/pack/commit/01438f00d44adf33f59da729b347eca60cb461a8

This patch was tested to work in a variety of situations and systems.

Possibly mandatory legalese: I disclaim any copyright to this patch thereby placing it in the public domain, in line with the public domain status of minimal/do.

EliteTK avatar Aug 06 '21 15:08 EliteTK

I would advise to just test whether the executable bit is set, and leave shebang parsing to the OS, calling the script with /bin/sh otherwise. There is a good reason, why Unix avoids executing arbitrary files and I've always found it strange that this redo implementation operates around the executable bit.

spacefrogg avatar Nov 30 '21 16:11 spacefrogg