Skip to content

Commit 599b68b

Browse files
committed
Reworked teardown_env.sh to use null-terminated paths when discovering mounts, and process the records through printf '%b'
for space resolution
1 parent ea606d5 commit 599b68b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

teardown_env.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,9 @@ if [[ -z "${TARGET_DIR}" ]]; then
8383
fi
8484

8585
# Real work
86-
status "Getting mounts in '${TARGET_DIR}'..."
87-
mounts=$(cat /proc/mounts | awk '{ system("echo \"" $2 "\"") }' | egrep "^${TARGET_DIR}" | tac)
88-
89-
status "Unmounting chroot filesystems..."
90-
for x in $mounts; do
86+
status "Unmounting chroot filesystems in '${TARGET_DIR}'..."
87+
while IFS= read -r -d '' x; do
9188
run umount "${x}"
92-
done
89+
done < <(cat /proc/mounts | tac | awk -vORS=$'\\0' '{ print $2 }' | xargs -0 -L1 printf '%b\0' | egrep --text --null-data "^${TARGET_DIR}")
9390

9491
status "Teardown complete"

0 commit comments

Comments
 (0)