Package: busybox Version: v1.29.0.git Severity: minor
If the numeric argument passed to ash's 'shift' built-in is greater than '$#' the command performs no operation and exits successfully. It should return a non-zero exit code instead:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#shift This is consistent with bash and hush.
>From 8673dc42ca5e63956116539d4087e7a55667d1cb Mon Sep 17 00:00:00 2001 From: Ingo van Lil <[email protected]> Date: Fri, 5 Jan 2018 15:04:23 +0100 Subject: [PATCH] ash: fail if 'shift' operand is out of range If the numeric argument passed to ash's 'shift' built-in is greater than '$#' the command performs no operation and exits successfully. It should return a non-zero exit code instead: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#shift This is consistent with bash and hush. Signed-off-by: Ingo van Lil <[email protected]> --- shell/ash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/ash.c b/shell/ash.c index dfb7d4d8e..b73a79975 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10858,7 +10858,7 @@ shiftcmd(int argc UNUSED_PARAM, char **argv) if (argv[1]) n = number(argv[1]); if (n > shellparam.nparam) - n = 0; /* bash compat, was = shellparam.nparam; */ + return 1; INT_OFF; shellparam.nparam -= n; for (ap1 = shellparam.p; --n >= 0; ap1++) { -- 2.13.6
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
