exercism / awk

Exercism exercises in AWK.
https://exercism.org/tracks/awk
MIT License
19 stars 22 forks source link

shebang is broken #158

Closed IsaacG closed 2 years ago

IsaacG commented 2 years ago
» head -n1 leap.awk
#!/usr/bin/env gawk -f
» chmod 755 leap.awk
» ./leap.awk <<< 2
/usr/bin/env: ‘gawk -f’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

# Modified shebang:
» head -n1 leap.awk
#!/usr/bin/env -S gawk -f
» ./leap.awk <<< 2
false

The shebang #!/usr/bin/env gawk -f is completely broken. "According to POSIX, the hashbang can have one argument." (see SO).

Our options here are (1) hard code a /usr/bin/gawk path or (2) rely on GNU env and -S or (3) drop the shebang and not rely on it.

See also Wikipedia and netbsd mail list

@glennj Thoughts?

glennj commented 2 years ago

I'd bet that 99.9% of students will have env -S. But probably best to just drop it. Maybe document it ... somewhere.