1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

Shell: Add some tests for subshells

This commit is contained in:
AnotherTest 2020-09-08 19:48:13 +04:30 committed by Andreas Kling
parent b194d79c53
commit 2488815bdb
Notes: sideshowbarker 2024-07-19 02:48:29 +09:00

28
Shell/Tests/subshell.sh Normal file
View file

@ -0,0 +1,28 @@
#/bin/sh
setopt --verbose
rm -rf shell-test
mkdir shell-test
cd shell-test
# Simple sequence (grouping)
{ echo test > testfile }
test "$(cat testfile)" = "test" || echo cannot write to file in subshell && exit 1
# Simple sequence - many commands
{ echo test1 > testfile; echo test2 > testfile }
test "$(cat testfile)" = "test2" || echo cannot write to file in subshell 2 && exit 1
# Does it exit with the last exit code?
{ test -z "a" }
exitcode=$?
test "$exitcode" -eq 1 || echo exits with $exitcode when it should exit with 1 && exit 1
{ test -z "a" || echo test }
exitcode=$?
test "$exitcode" -eq 0 || echo exits with $exitcode when it should exit with 0 && exit 1
cd ..
rm -rf shell-test