Hacker News new | ask | show | jobs
by fuzzybear3965 1537 days ago
Shells return exit codes, not typed error values. What kind of output would you expect from the shell, exactly?
2 comments

I'd expect the same as any other failure from execv(2). Something like,

  zsh: Exec format error: empty-file
  (last command returned 127.)
(127 is the exit status for other failures, so I've used it here. The second line is intended to be part of my PS1, the first zsh's normal reporting. The string used here is what I get from perror() for that code.)
Okay, yeah. That could be useful. Seems POSIX forces the behavior described in the blog post. Time to change the standard!
Status 129 or something else outside the usual range, plus a message that the file was not a valid ELF and also has no shebang, therefore cannot be executed.
I always thought that 128+ are for (shell-spawned) processes and 0-127 are for shell. But, apparently POSIX requires this behavior for empty files - we need to amend the standard, first (or fail to comply, muahahaha).