Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-12 01:36:58 +0300
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-12 01:36:58 +0300
commit272710fe938d122617e35989f071f083d959e13f (patch)
treeef4d028f8aeea4412a4d1880caebba5549c40f27 /coreutils
parent98f5cdfca7401e4e159b73b1efa600ca58fb292d (diff)
expr: on error, exit with exitcode 2
expr_main 101 110 +9
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/expr.c11
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)
}
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));
}