Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is possible for the shell to handle it. From zshall(1):

> If the program is a file beginning with ‘#!', the remainder of the first line specifies an interpreter for the program. The shell will execute the specified interpreter on operating systems that do not handle this executable format in the kernel.

Taking a quick look at the source in Src/exec.c:

  execve(pth, argv, newenvp);
  // [...]
  if ((eno = errno) == ENOEXEC || eno == ENOENT) {
              // [...]
              if (ct >= 2 && execvebuf[0] == '#' && execvebuf[1] == '!') {
                                // [...]
                                (pprog = pathprog(ptr2, NULL))) {
I guess at some point someone added that `|| eno == ENOENT` and the docs weren't updated.


I did a little digging and found that the `|| eno == ENOENT` was added quite a bit earlier[1] than the actual pathprog lookup[2]. While I could find the "issue discussion" for the pathprog change[3] I wasn't able to find it for the ENOENT addition, which was kind of interesting and frustrating--[4] is the `X-Seq` mentioned in the commit but that seems to be inconsistent or incorrect for the actual cross-reference, and nearby in time wasn't helpful either.

[1] https://sourceforge.net/p/zsh/code/ci/29ed6c7e3ab32da20f528a...

[2] https://sourceforge.net/p/zsh/code/ci/29ed6c7e3ab32da20f528a...

[3] https://www.zsh.org/mla/workers/2010/msg00522.html

[4] https://www.zsh.org/mla/workers/2000/msg01168.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: