It is commonly known that
env does not allow passing of arguments - at least not reliably. There are various workarounds described here, but they felt to hacky and unreadable to me. That's why I developed an alternative,
#!/usr/bin/env bash # save the string given in the sheband line shebang_line="$1" # remove it from $@ shift # execute # not quoting shebang_line is intentional eval $(echo $shebang_line "$@")
#!/usr/local/bin/ex python "-i" # quoting the arguments is possible import sys print('hello', sys.argv)
It works surprisingly well, but I don't like the eval-echo thing. I tried experimenting with arrays, but haven't found a solution. Any tips?