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
path: root/shell
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-21 02:22:18 +0400
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-21 02:22:18 +0400
commit004baba2d6857a3cc0c5d25020ec257169a2d2b7 (patch)
tree2d96ca56349fe8400e44f7f07dd33e2e2f908c1b /shell
parent262d7653514f2b94c3aea4dac31b09e46b8b1c15 (diff)
hush: fix shift + $0 bug; add testcase
Diffstat (limited to 'shell')
-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)
n = atoi(argv[1]);
}
if (n >= 0 && n < global_argc) {
- /* XXX This probably breaks $0 */
+ global_argv[n] = global_argv[0];
global_argc -= n;
global_argv += n;
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 @@
+./shift.tests abc d e
+./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 @@
+if test $# = 0; then
+ exec "$THIS_SH" $0 abc "d e"
+fi
+echo $0 $1 $2
+shift
+echo $0 $1 $2