aboutsummaryrefslogtreecommitdiff
path: root/coreutils/env.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/env.c')
-rw-r--r--coreutils/env.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/coreutils/env.c b/coreutils/env.c
index 1a8ad7c78..d59e738f1 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -38,7 +38,7 @@
38 * - correct "-" option usage 38 * - correct "-" option usage
39 * - multiple "-u unsetenv" support 39 * - multiple "-u unsetenv" support
40 * - GNU long option support 40 * - GNU long option support
41 * - save errno after exec failed before bb_perror_msg() 41 * - use bb_default_error_retval
42 */ 42 */
43 43
44 44
@@ -65,7 +65,7 @@ extern int env_main(int argc, char** argv)
65 llist_t *unset_env = NULL; 65 llist_t *unset_env = NULL;
66 extern char **environ; 66 extern char **environ;
67 67
68 bb_opt_complementally = "u*"; 68 bb_opt_complementally = "u::";
69 bb_applet_long_options = env_long_options; 69 bb_applet_long_options = env_long_options;
70 70
71 opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env); 71 opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env);
@@ -93,12 +93,10 @@ extern int env_main(int argc, char** argv)
93 } 93 }
94 94
95 if (*argv) { 95 if (*argv) {
96 int er;
97
98 execvp(*argv, argv); 96 execvp(*argv, argv);
99 er = errno; 97 /* SUSv3-mandated exit codes. */
100 bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */ 98 bb_default_error_retval = (errno == ENOENT) ? 127 : 126;
101 return (er == ENOENT) ? 127 : 126; /* SUSv3-mandated exit codes. */ 99 bb_perror_msg_and_die("%s", *argv);
102 } 100 }
103 101
104 for (ep = environ; *ep; ep++) { 102 for (ep = environ; *ep; ep++) {