Is it know that most shebang
implementations will support a single parameter so if you have something like
#!/usr/bin/env some-tool-accepting-yaml param1 param2
... (yaml body)
It will now work as expected because it will call the tool with "param1 param2" argument instead of splitting it into two arguments.
It seems that one workaround practice is to use something like:
#!/bin/sh
arbitrary_long_name==0 "exec" "/usr/bin/gawk" "--re-interval" "-f" "$0" "$@"
Now this approach would make YAML-based script invalid due to the 2nd line, so the only acceptable workaround would be one that is also a comment, starting with "#" too.
Is there a way to bypass this issue too?
We can't have multiple shebang lines - there can only be one and it should always be the first line. If you need to support multiple versions of Python based on OS, it is best to write a small shell wrapper that invokes your python script with the right interpreter, probably with an exec .
The shebang line is usually ignored by the interpreter, because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments still may ignore the shebang line in recognition of its purpose.
A general solution without using polyglot scripts
#!/bin/bash
# first argument to be split
if [[ $- != *f* ]]; then reset=1; fi
set -f
arg=( $1 )
shift
if [[ $reset = 1 ]]; then set +f; fi
# other arguments
arg+=("$@")
# launch command
exec "${arg[@]}"
#!/path/to/launcher.sh interpreter opts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With