chroot(1) is documented to run "$SHELL -i" as the default command. Let's do
something similar and call "sh -i". When a user is using '--debug-shell' and one
of the scripts fails, the mkosi-chroot can be used to chroot into the image.
I think this is what users expect, based on the 'chroot' in the name.
(I don't think using $SHELL makes sense. It could either be set to 'sh', or to
something from the outside, which might not even be installed in the chroot. We
call 'sh' ourselves, so we know it must be there, so let's just call that
uncoditionally.)
DIR="$(cd "$(dirname "$0")" && pwd)"
PATH="$(echo "$PATH" | tr ':' '\\n' | grep -v "$DIR" | tr '\\n' ':')"
export PATH
- exec {shlex.join(str(s) for s in script)} "$@"
+ if [ $# -gt 0 ]; then
+ exec {shlex.join(str(s) for s in script)} "$@"
+ else
+ exec {shlex.join(str(s) for s in script)} sh -i
+ fi
"""
)
)