aboutsummaryrefslogtreecommitdiff
path: root/coreutils/printenv.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/printenv.c')
-rw-r--r--coreutils/printenv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/coreutils/printenv.c b/coreutils/printenv.c
index 6971f7258..2430f3a1a 100644
--- a/coreutils/printenv.c
+++ b/coreutils/printenv.c
@@ -13,6 +13,8 @@
13int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 13int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
14int printenv_main(int argc UNUSED_PARAM, char **argv) 14int printenv_main(int argc UNUSED_PARAM, char **argv)
15{ 15{
16 int exit_code = EXIT_SUCCESS;
17
16 /* no variables specified, show whole env */ 18 /* no variables specified, show whole env */
17 if (!argv[1]) { 19 if (!argv[1]) {
18 int e = 0; 20 int e = 0;
@@ -26,8 +28,10 @@ int printenv_main(int argc UNUSED_PARAM, char **argv)
26 env = getenv(arg); 28 env = getenv(arg);
27 if (env) 29 if (env)
28 puts(env); 30 puts(env);
31 else
32 exit_code = EXIT_FAILURE;
29 } 33 }
30 } 34 }
31 35
32 fflush_stdout_and_exit(EXIT_SUCCESS); 36 fflush_stdout_and_exit(exit_code);
33} 37}