script icon indicating copy to clipboard operation
script copied to clipboard

Exit status code for command not found

Open thiagonache opened this issue 3 years ago • 0 comments

Hi @bitfield,

I believe I've found a reason why script should return a specific status code for command not found There are only 4 reasons to make an exec fail:

  1. E2BIG - The argument list exceeds the system limit.
  2. EACCES - The specified file has a locking or sharing violation.
  3. ENOENT - The file or path name not found.
  4. ENOMEM - Not enough memory is available to execute the new process image.

The syscall exec sets errno ENOENT. It doesn't need to be 127 but I think it's quite convenient since we are "porting" shell scripts to Go.

Reference https://en.wikipedia.org/wiki/Exec_(system_call)

thiagonache avatar Jun 09 '22 10:06 thiagonache