1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

Shell: Add support for ARGV (and $*, $#)

This patchset also adds the 'shift' builtin, as well as the usual tests.
closes #2948.
This commit is contained in:
AnotherTest 2020-08-04 09:27:25 +04:30 committed by Andreas Kling
parent 192b2383ac
commit 12af65c1c9
8 changed files with 79 additions and 1 deletions

View file

@ -0,0 +1,15 @@
#!/bin/sh
test "$*" = "" || echo "Fail: Argv list not empty" && exit 1
test "$#" -eq 0 || echo "Fail: Argv list empty but count non-zero" && exit 1
test "$ARGV" = "$*" || echo "Fail: \$ARGV not equal to \$*" && exit 1
ARGV=(1 2 3)
test "$#" -eq 3 || echo "Fail: Assignment to ARGV does not affect \$#" && exit 1
test "$*" = "1 2 3" || echo "Fail: Assignment to ARGV does not affect \$*" && exit 1
shift
test "$*" = "2 3" || echo "Fail: 'shift' does not work correctly" && exit 1
shift 2
test "$*" = "" || echo "Fail: 'shift 2' does not work correctly" && exit 1