forked from kiss-community/kiss
kiss-chroot: fix trap
If the chroot is exited with nonzero status, kiss-chroot runs `die chroot failed`. Then, die runs `exit 1` which causes the trap to execute. However, in this scope, "$@" is "chroot failed", so the trap evaluates $1 to be "chroot" rather than the mountpoint given to the kiss-chroot script. Then, the trap tries to unmount "chroot/dev" etc rather than the true mountpoint. This patch uses double quotes rather than single when setting the trap, so that $1 is expanded then and the mountpoint is stored for when the trap is called.
This commit is contained in:
parent
363fcaf71c
commit
c6c851b645
@ -57,7 +57,9 @@ main() {
|
||||
[ -d "$1" ] || die Given path does not exist
|
||||
[ "$(id -u)" = 0 ] || die Script needs to be run as root
|
||||
|
||||
trap 'clean "${1%"${1##*[!/]}"}"' EXIT INT
|
||||
# Intended behaviour.
|
||||
# shellcheck disable=SC2064
|
||||
trap "clean ${1%"${1##*[!/]}"}" EXIT INT
|
||||
|
||||
log Mounting host paths; {
|
||||
mmount "$1/dev" -o bind /dev
|
||||
|
Loading…
Reference in New Issue
Block a user