aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo van Lil <inguin@gmx.de>2018-01-05 15:04:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-01-07 14:22:38 +0100
commit9c8e94bc0a3836dd6b8acbcf1fa88283a0a3c148 (patch)
tree9f07ea59974e3863edef50f1a01047de729b2e3d
parent6f4a785bd1bd0e6973b5c27b34b86655b1d7a602 (diff)
downloadbusybox-w32-9c8e94bc0a3836dd6b8acbcf1fa88283a0a3c148.tar.gz
busybox-w32-9c8e94bc0a3836dd6b8acbcf1fa88283a0a3c148.tar.bz2
busybox-w32-9c8e94bc0a3836dd6b8acbcf1fa88283a0a3c148.zip
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. function old new delta shiftcmd 122 120 -2 Signed-off-by: Ingo van Lil <inguin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c2
1 files changed, 1 insertions, 1 deletions
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)
10858 if (argv[1]) 10858 if (argv[1])
10859 n = number(argv[1]); 10859 n = number(argv[1]);
10860 if (n > shellparam.nparam) 10860 if (n > shellparam.nparam)
10861 n = 0; /* bash compat, was = shellparam.nparam; */ 10861 return 1;
10862 INT_OFF; 10862 INT_OFF;
10863 shellparam.nparam -= n; 10863 shellparam.nparam -= n;
10864 for (ap1 = shellparam.p; --n >= 0; ap1++) { 10864 for (ap1 = shellparam.p; --n >= 0; ap1++) {