Skip to content

Commit 097d27c

Browse files
committed
run_qemu.sh: use the { main; exit "$?"; } trick to allow modifications
Wrap main around a new compound statement { } to force bash to read it entirely before running it. This allows modifying the script while it's running. Credits to Simon Tatham https://hachyderm.io/@simontatham/114511220670677410 Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 0ceb908 commit 097d27c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

run_qemu.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ exit_handler()
290290
exit "$err"
291291
}
292292

293+
# Silence SC2317 and SC2329
294+
# https://github.com/koalaman/shellcheck/issues/2542
295+
false && exit_handler "$@"
293296

294297
# Runs a command repeatedly until it succeeds. Returns true as soon as the command returns
295298
# true before the timeout. Otherwise returns false and prints a timeout message.
@@ -2055,4 +2058,9 @@ main()
20552058
fi
20562059
}
20572060

2058-
main
2061+
# This compound statement { } forces bash to read it entirely before
2062+
# running it. This allows modifying the script while it's running.
2063+
# https://hachyderm.io/@simontatham/114511220670677410
2064+
{
2065+
main; exit $?
2066+
}

0 commit comments

Comments
 (0)