aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--shell/hush.c2
-rw-r--r--shell/hush_test/hush-misc/shift.right2
-rw-r--r--shell/hush_test/hush-misc/shift.tests6
3 files changed, 9 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 0d260a762..107b821f8 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -952,7 +952,7 @@ static int builtin_shift(char **argv)
952 n = atoi(argv[1]); 952 n = atoi(argv[1]);
953 } 953 }
954 if (n >= 0 && n < global_argc) { 954 if (n >= 0 && n < global_argc) {
955 /* XXX This probably breaks $0 */ 955 global_argv[n] = global_argv[0];
956 global_argc -= n; 956 global_argc -= n;
957 global_argv += n; 957 global_argv += n;
958 return EXIT_SUCCESS; 958 return EXIT_SUCCESS;
diff --git a/shell/hush_test/hush-misc/shift.right b/shell/hush_test/hush-misc/shift.right
new file mode 100644
index 000000000..afb90be9c
--- /dev/null
+++ b/shell/hush_test/hush-misc/shift.right
@@ -0,0 +1,2 @@
1./shift.tests abc d e
2./shift.tests d e
diff --git a/shell/hush_test/hush-misc/shift.tests b/shell/hush_test/hush-misc/shift.tests
new file mode 100644
index 000000000..17f2c9f36
--- /dev/null
+++ b/shell/hush_test/hush-misc/shift.tests
@@ -0,0 +1,6 @@
1if test $# = 0; then
2 exec "$THIS_SH" $0 abc "d e"
3fi
4echo $0 $1 $2
5shift
6echo $0 $1 $2