hush: fix shift + $0 bug; add testcase
This commit is contained in:
parent
262d765351
commit
004baba2d6
@ -952,7 +952,7 @@ static int builtin_shift(char **argv)
|
|||||||
n = atoi(argv[1]);
|
n = atoi(argv[1]);
|
||||||
}
|
}
|
||||||
if (n >= 0 && n < global_argc) {
|
if (n >= 0 && n < global_argc) {
|
||||||
/* XXX This probably breaks $0 */
|
global_argv[n] = global_argv[0];
|
||||||
global_argc -= n;
|
global_argc -= n;
|
||||||
global_argv += n;
|
global_argv += n;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
2
shell/hush_test/hush-misc/shift.right
Normal file
2
shell/hush_test/hush-misc/shift.right
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
./shift.tests abc d e
|
||||||
|
./shift.tests d e
|
6
shell/hush_test/hush-misc/shift.tests
Normal file
6
shell/hush_test/hush-misc/shift.tests
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user