Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimal/do: allow for relative shebangs #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EliteTK
Copy link

@EliteTK EliteTK commented Aug 6, 2021

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.

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.
@spacefrogg
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants