Skip to main content
9 events
when toggle format what by license comment
Feb 21, 2017 at 1:55 comment added Gilles 'SO- stop being evil' @muru POSIX doesn't say anything about executable formats, it doesn't even codify shebang. A valid format is whatever the kernel accepts. An invalid format is whatever the kernel returns ENOEXEC on. Virtually anything that could be called Unix supports shebang as one of its executable formats, but there are other POSIX systems that don't, such as Windows NT's POSIX subsystem.
Feb 21, 2017 at 1:49 comment added muru @Gilles hmm, I though valid format meant something like ELF or a.out, since it doesn't say an interpreter script is a valid format for execve.
Feb 21, 2017 at 1:29 comment added Gilles 'SO- stop being evil' Note that the part of your answer about execlp and execvp running scripts with sh does not apply here. It would apply if 1. the caller was calling one of these functions rather than some other wrapper for the execve system call, and 2. the execve call returned ENOEXEC. But here execve doesn't return ENOEXEC, because foo.sh does have a valid format — it starts with a shebang. The kernel tries to execute env and that fails with ENOENT because there's no file called env.
Feb 21, 2017 at 1:26 comment added Gilles 'SO- stop being evil' That's arguably a bug in zsh. Bash and zsh both try to emulate the #! mechanism (in case they're running on some exotic system that doesn't support shebangs). Bash does it faithfully. Zsh performs a PATH lookup for the shebang program, which in principle is helpful but has the downside of being a zsh-specific thing.
Feb 20, 2017 at 5:45 comment added muru @flavio use /bin/sh as the shebang, then at the start of the script, try to locate bash (or whatever it is you'd do with env) and use bash to run the script.
Feb 20, 2017 at 5:44 history edited muru CC BY-SA 3.0
added 15 characters in body
Feb 20, 2017 at 5:43 comment added flavio That's very good answer! :) I can accept it but can't give a "plus", because i have no privileges to do so yet (I will never understand why they do that here...) I asked this on serverfault because i was trying to figure out if one could use env to circumvent non default installs, but that show I can't do that way. Need to think more.
Feb 20, 2017 at 5:37 vote accept flavio
Feb 23, 2017 at 7:41
Feb 20, 2017 at 3:55 history answered muru CC BY-SA 3.0