4 ms·
IIRC in a hashbang isn't posix compatible
by snek 7y ago
IIRC in a hashbang isn't posix compatible
- emmelaich 7y agoArgs in a hashbang? Maybe not, but I'm pretty sure every system supports a single arg. And very few (none?) support more.
- eridius 7y agomacOS appears to support multiple args just fine. Which is why it annoys me that Shellcheck bitches about using more than one arg even though I'm writing a script for macOS specifically.
- Splognosticus 7y agoShellCheck is right insofar as compatibility is concerned. You can only rely on the shebang supporting one argument. I'd personally just ignore that warning if I were writing for MacOS specifically, but you can configure ShellCheck to ignore certain errors that you don't care about[1]. [1] https://github.com/koalaman/shellcheck/wiki/Ignore https://github.com/koalaman/shellcheck/wiki/Ignore
- eridius 7y agoYeah, but it's simpler just to move the additional args to `set` calls than to remember the syntax for disabling the directive. It's just irritating, and especially so because, for some reason, in VSCode it ends up highlighting literally the entire file as an error instead of just the shebang.
- TheDong 7y agoA hashbang is not defined by posix, so using it without args isn't "posix compatible". From https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V... > If the first line of a file of shell commands starts with the characters "#!", the results are unspecified. There is no more specification for "#!/usr/bash" than "#!/usr/bin/jq -jf" The exec page provides even fewer words about how to interpret shebangs if you thought perhaps I was linking to the wrong portion of the posix spec