Without them only the last expression's return value is honored, causing
unexpected CI fails:
[ 26.006721] testsuite-04.sh[1191]: + for _ in {0..9}
[ 26.007672] testsuite-04.sh[1191]: + setterm --term linux --dump --file /tmp/console.dump
[ 26.008871] testsuite-04.sh[1233]: + SYSTEMD_COLORS=256
[ 26.009606] testsuite-04.sh[1233]: + /usr/lib/systemd/systemd-bsod
[ 26.063296] systemd[1]: session-1.scope: Deactivated successfully.
[ 26.124789] testsuite-04.sh[1191]: + grep -aq 'Press any key to exit' /tmp/console.dump
[ 26.131509] testsuite-04.sh[1191]: + grep -aq 'Root emergency message' /tmp/console.dump
[ 26.137882] testsuite-04.sh[1191]: + grep -aq 'The current boot has failed' /tmp/console.dump
[ 26.141650] testsuite-04.sh[1191]: + return 0
[ 26.144816] testsuite-04.sh[1191]: + grep -aq 'Scan the QR code' /tmp/console.dump
[ 26.153591] testsuite-04.sh[1191]: + at_exit
[ 26.154744] testsuite-04.sh[1191]: + local EC=1
[ 26.155697] testsuite-04.sh[1191]: + [[ 1 -ne 0 ]]
[ 26.156787] testsuite-04.sh[1191]: + [[ -e /tmp/console.dump ]]
[ 26.157799] testsuite-04.sh[1191]: + cat /tmp/console.dump
[ 26.158858] testsuite-04.sh[1244]: The current boot has failed!
[ 26.159858] testsuite-04.sh[1244]: Root emergency message
I'm genuinely impressed that this worked at all.
# so try it a couple of times
for _ in {0..9}; do
setterm --term linux --dump --file /tmp/console.dump
- if grep -aq "Press any key to exit" /tmp/console.dump
- grep -aq "$expected_message" /tmp/console.dump
- grep -aq "The current boot has failed" /tmp/console.dump; then
+ if grep -aq "Press any key to exit" /tmp/console.dump &&
+ grep -aq "$expected_message" /tmp/console.dump &&
+ grep -aq "The current boot has failed" /tmp/console.dump; then
return 0
fi