3 ms·
Using spaces in a shebang is not a standard thing and doesn’t work in most shells.
by WhyNotHugo 3y ago
Using spaces in a shebang is not a standard thing and doesn’t work in most shells.
- jstanley 3y agoThe spaces are being handled by `env`: $ env "-S echo hello world" hello world https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html#g_t_002dS_002f_002d_002dsplit_002dstring-usage-in-scripts https://www.gnu.org/software/coreutils/manual/html_node/env-...
- flakes 3y agoCurious for what systems this does not work? I start a lot of my shebangs with `#!/usr/bin/env <app>` such that I can rely on PATH for resolving application locations.
- chuckadams 3y agoJust plain #!app also works. Probably less portable, but it does work on linux and macOS. Not sure if POSIX has anything to say about shebangs.
- flakes 3y agoHuh, I guess I've never given it too much thought. I was under the impression for some reason that the first argument was supposed to be an absolute path.
- chuckadams 3y agoIt might have had to be absolute on ancient Unixen ... Unices? Seems POSIX has all of this to say about shebangs: If the first line of a file of shell commands starts with the characters "#!", the results are unspecified. So it's basically all down to convention, but one that's been followed long enough that you can rely on it. I still don't count on shebang taking more than one argument to the command though.