1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 01:14:58 +00:00
serenity/Shell/Tests/if.sh
AnotherTest 715e11f692 Shell: Fix job control and backgrounding
This patchset makes the shell capable of lazily resolving and executing
sequences of commands, to allow for putting logical sequences in the
background.
In particular, it enables And/Or/Sequence nodes to be run in the background,
and consequently unmarks them as `would_execute`.
Doing so also fixes job control to an extent, as jobs are now capable of
having 'tails', so sequences can be put in the background while
preserving their following sequences.
2020-09-09 20:35:21 +02:00

50 lines
1 KiB
Bash

#!/bin/sh
setopt --verbose
if test 1 -eq 1 {
# Are comments ok?
# Basic 'if' structure, empty block.
if true {
} else {
echo "if true runs false branch"
exit 2
}
if false {
echo "if false runs true branch"
exit 2
} else {
}
# Basic 'if' structure, without 'else'
if false {
echo "Fail: 'if false' runs the branch"
exit 2
}
# Extended 'cond' form.
if false {
echo "Fail: 'if false' with 'else if' runs first branch"
exit 2
} else if true {
} else {
echo "Fail: 'if false' with 'else if' runs last branch"
exit 2
}
# FIXME: Some form of 'not' would be nice
# &&/|| in condition
if true || false {
} else {
echo "Fail: 'if true || false' runs false branch"
exit 2
}
if true && false {
echo "Fail: 'if true && false' runs true branch"
exit 2
}
} else {
echo "Fail: 'if test 1 -eq 1' runs false branch"
exit 1
}