I read in another answer that I'm not able to pass arguments to the interpreter than I'm giving to /usr/bin/env:
Another potential problem is that the
#!/usr/bin/envtrick doesn't let you pass arguments to the interpreter (other than the name of the script, which is passed implicitly).
However, it looks like I am able to, because awk is breaking when I don't give it the -f flag and it's fixed when I do give it the -f flag, while using /usr/bin/env:
First, without the -f flag:
$ cat wrap_in_quotes
#!/usr/bin/env awk
# wrap each line in quotes
# usage: wrap_in_quotes [ file ... ]
{ print "\""$0"\"" }
$ echo foobar | ./wrap_in_quotes
awk: syntax error at source line 1
context is
>>> . <<< /wrap_in_quotes
awk: bailing out at source line 1
Second, with the -f flag:
$ vim wrap_in_quotes
$ cat wrap_in_quotes
#!/usr/bin/env awk -f
# wrap each line in quotes
# usage: wrap_in_quotes [ file ... ]
{ print "\""$0"\"" }
$ echo foobar | ./wrap_in_quotes
"foobar"
- So, if according to the linked answer I'm not able to pass flags to the interpreter, why am I able to pass the
-fflag toawk?
I'm running macOS:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.1
BuildVersion: 16B2657