Can I get arguments that happen to be AWK options passed directly to a pure AWK script?
Example script:
#!/usr/bin/env -S awk -f
BEGIN { if (ARGV[1] == "-h") print "whoop" }
I want ./myscript -h
to print whoop. But AWK gets the -h first and prints its usage instead.
Running ./myscript -- -h
works but I can't get -- working in the shebang because of the -f.
I know I could use a shell script with AWK in instead.
#!
line that you use, so I can't test this: Add--
at the end of the#!
line.env -S awk -f -- ./myscript -h
, while what I think they need isenv -S awk -f ./myscript -- -h
. I think that's what the second to last paragraph is trying to say.#!
line, a shell script sounds like a good idea.#!
. IIRC FreeBSD used to, but that was long time ago.