3 ms·
Synopsis of the idea: #!/path/to/interpreter one-allowed-arg<NUL>trailing material<LF> The kernel is written in C, and so its hash bang mechanism only sees
by kazinator 8y ago
Synopsis of the idea:
#!/path/to/interpreter one-allowed-arg<NUL>trailing material<LF>
The kernel is written in C, and so its hash bang mechanism only sees "#!/path/to/interpreter one-allowed-arg".
The interpreter executes with that argument, and then opens the script, looks for the NUL character in the first line and retrieves and parses the additional arguments { "trailing", "material" }, combining them into { "one-allowed-arg", "trailing", "material" }.
Advantage: this can be retrofitted into just about any interpreter without disturbing the language. Alternatives like encoding the extra args on the following line are more disruptive.
Tested on Linux, MacOS, Solaris and Cygwin.