svn commit: trunk/busybox/coreutils

vda at busybox.net vda at busybox.net
Tue Nov 11 22:36:58 UTC 2008


Author: vda
Date: 2008-11-11 14:36:58 -0800 (Tue, 11 Nov 2008)
New Revision: 24007

Log:
expr: on error, exit with exitcode 2

expr_main                                            101     110      +9



Modified:
   trunk/busybox/coreutils/expr.c


Changeset:
Modified: trunk/busybox/coreutils/expr.c
===================================================================
--- trunk/busybox/coreutils/expr.c	2008-11-11 22:25:34 UTC (rev 24006)
+++ trunk/busybox/coreutils/expr.c	2008-11-11 22:36:58 UTC (rev 24007)
@@ -481,24 +481,21 @@
 }
 
 int expr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int expr_main(int argc, char **argv)
+int expr_main(int argc UNUSED_PARAM, char **argv)
 {
 	VALUE *v;
 
-	if (argc == 1) {
+	xfunc_error_retval = 2; /* coreutils compat */
+	G.args = argv + 1;
+	if (*G.args == NULL) {
 		bb_error_msg_and_die("too few arguments");
 	}
-
-	G.args = argv + 1;
-
 	v = eval();
 	if (*G.args)
 		bb_error_msg_and_die("syntax error");
-
 	if (v->type == INTEGER)
 		printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
 	else
 		puts(v->u.s);
-
 	fflush_stdout_and_exit(null(v));
 }




More information about the busybox-cvs mailing list