diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-11 22:36:58 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-11 22:36:58 +0000 |
commit | 272710fe938d122617e35989f071f083d959e13f (patch) | |
tree | ef4d028f8aeea4412a4d1880caebba5549c40f27 | |
parent | 98f5cdfca7401e4e159b73b1efa600ca58fb292d (diff) | |
download | busybox-w32-272710fe938d122617e35989f071f083d959e13f.tar.gz busybox-w32-272710fe938d122617e35989f071f083d959e13f.tar.bz2 busybox-w32-272710fe938d122617e35989f071f083d959e13f.zip |
expr: on error, exit with exitcode 2
expr_main 101 110 +9
-rw-r--r-- | coreutils/expr.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/coreutils/expr.c b/coreutils/expr.c index 2f9c5c1e3..d659b670b 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
@@ -481,24 +481,21 @@ static VALUE *eval(void) | |||
481 | } | 481 | } |
482 | 482 | ||
483 | int expr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 483 | int expr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
484 | int expr_main(int argc, char **argv) | 484 | int expr_main(int argc UNUSED_PARAM, char **argv) |
485 | { | 485 | { |
486 | VALUE *v; | 486 | VALUE *v; |
487 | 487 | ||
488 | if (argc == 1) { | 488 | xfunc_error_retval = 2; /* coreutils compat */ |
489 | G.args = argv + 1; | ||
490 | if (*G.args == NULL) { | ||
489 | bb_error_msg_and_die("too few arguments"); | 491 | bb_error_msg_and_die("too few arguments"); |
490 | } | 492 | } |
491 | |||
492 | G.args = argv + 1; | ||
493 | |||
494 | v = eval(); | 493 | v = eval(); |
495 | if (*G.args) | 494 | if (*G.args) |
496 | bb_error_msg_and_die("syntax error"); | 495 | bb_error_msg_and_die("syntax error"); |
497 | |||
498 | if (v->type == INTEGER) | 496 | if (v->type == INTEGER) |
499 | printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i); | 497 | printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i); |
500 | else | 498 | else |
501 | puts(v->u.s); | 499 | puts(v->u.s); |
502 | |||
503 | fflush_stdout_and_exit(null(v)); | 500 | fflush_stdout_and_exit(null(v)); |
504 | } | 501 | } |