Support arguments in shebang (#!)
Closes: #199 (closed)
The follow patch updates the shebang parser so that it supports passing arguments to the interpreter. For example...
#! /usr/bin/env -S python -OO
assert False
print("I still work")
...is a valid hashbang. This demonstrates a space after the magic bytes (implemented in a previous patch), passing an argument to the "interpreter" (env, in this case) which passes arguments to the real interpreter (python).
I implemented this by copying everything after the interpreter to treat as an argument to the interpreter. Linux and FreeBSD follow the same paradigm whereas macOS splits the arguments itself (like env -S
).
There no spec for #!
. Linux, FreeBSD, macOS, and now Redox are all valid. I opted for Linux and FreeBSD's solution because it's simpler but still portable since well behaved scripts will use env
anyway.
Sources: