svn commit: trunk/busybox/coreutils

vda at busybox.net vda at busybox.net
Tue Nov 11 22:59:42 UTC 2008


Author: vda
Date: 2008-11-11 14:59:41 -0800 (Tue, 11 Nov 2008)
New Revision: 24009

Log:
cksum, printenv: report errors via exitcode

function                                             old     new   delta
cksum_main                                           296     315     +19
printenv_main                                         74      86     +12



Modified:
   trunk/busybox/coreutils/cksum.c
   trunk/busybox/coreutils/printenv.c


Changeset:
Modified: trunk/busybox/coreutils/cksum.c
===================================================================
--- trunk/busybox/coreutils/cksum.c	2008-11-11 22:43:10 UTC (rev 24008)
+++ trunk/busybox/coreutils/cksum.c	2008-11-11 22:59:41 UTC (rev 24009)
@@ -15,6 +15,7 @@
 	uint32_t crc;
 	off_t length, filesize;
 	int bytes_read;
+	int exit_code = EXIT_SUCCESS;
 	uint8_t *cp;
 
 #if ENABLE_DESKTOP
@@ -27,8 +28,10 @@
 	do {
 		int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
 
-		if (fd < 0)
+		if (fd < 0) {
+			exit_code = EXIT_FAILURE;
 			continue;
+		}
 		crc = 0;
 		length = 0;
 
@@ -60,5 +63,5 @@
 				crc, filesize, *argv);
 	} while (*argv && *++argv);
 
-	fflush_stdout_and_exit(EXIT_SUCCESS);
+	fflush_stdout_and_exit(exit_code);
 }

Modified: trunk/busybox/coreutils/printenv.c
===================================================================
--- trunk/busybox/coreutils/printenv.c	2008-11-11 22:43:10 UTC (rev 24008)
+++ trunk/busybox/coreutils/printenv.c	2008-11-11 22:59:41 UTC (rev 24009)
@@ -13,6 +13,8 @@
 int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int printenv_main(int argc UNUSED_PARAM, char **argv)
 {
+	int exit_code = EXIT_SUCCESS;
+
 	/* no variables specified, show whole env */
 	if (!argv[1]) {
 		int e = 0;
@@ -26,8 +28,10 @@
 			env = getenv(arg);
 			if (env)
 				puts(env);
+			else
+				exit_code = EXIT_FAILURE;
 		}
 	}
 
-	fflush_stdout_and_exit(EXIT_SUCCESS);
+	fflush_stdout_and_exit(exit_code);
 }




More information about the busybox-cvs mailing list