Scripts are executed as #!interpreter [arg]
and most often as
#!/usr/bin/env interpreter
. As older versions of env did not support
additional arguments, clever hacks were needed instead. This repo catalogs
single file workarounds.
Modern env users should always favor -S
/ --split-string=
instead of any of
these hacks. Eg:
#!/usr/bin/env -S deno --quiet run --allow-read --allow-write --check=typescript
- Must be self-contained as a single file executable
- Must support any number of interpreter arguments inline
- Must use
#!/usr/bin/env interpreter
- Must echo the first argument with zero exit status
- Must exit with nonzero status when no argument
- Must work as any filename but should be named after the target program
- Should be a paradigm (terse, clear, extensible)
- May (or may not) work when the script in its entirety is interpreted
by interpreter. For example,
python demo/python $RANDOM
anddemo/python $RANDOM
are equivalent but onlydemo/make $RANDOM
, notmake -f demo/make $RANDOM
works
All code in this repository is public domain and may be used without limitation.