]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(run_shell): Exit with status 126 or 127 when execvp or
authorJim Meyering <jim@meyering.net>
Thu, 1 Aug 2002 09:19:24 +0000 (09:19 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 1 Aug 2002 09:19:24 +0000 (09:19 +0000)
execv fails, for consistency with POSIX commands like env and nice.

src/su.c

index 65bb8b3fc518c78b744361a27574ef48d4caf724..3d834679efec454ae0b1864e9aaad8111b189e46 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -397,8 +397,12 @@ run_shell (const char *shell, const char *command, char **additional_args)
       args[argno++] = *additional_args;
   args[argno] = NULL;
   execv (shell, (char **) args);
-  error (0, errno, _("cannot run %s"), shell);
-  exit (1);
+
+  {
+    int exit_status = (errno == ENOENT ? 127 : 126);
+    error (0, errno, "%s", shell);
+    exit (exit_status);
+  }
 }
 
 /* Return 1 if SHELL is a restricted shell (one not returned by