Replace unmount read loop with awk

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
Brad Davidson 2020-09-10 15:44:09 -07:00 committed by Brad Davidson
parent 041f18f6da
commit 5ad76043ac
2 changed files with 2 additions and 24 deletions

View File

@ -546,18 +546,7 @@ getshims() {
killtree $({ set +x; } 2>/dev/null; getshims; set -x)
do_unmount() {
{ set +x; } 2>/dev/null
MOUNTS=
while read ignore mount ignore; do
MOUNTS="$mount\n$MOUNTS"
done </proc/self/mounts
MOUNTS=$(printf $MOUNTS | grep "^$1" | sort -r)
if [ -n "${MOUNTS}" ]; then
set -x
xargs -n 1 umount <<< ${MOUNTS}
else
set -x
fi
awk -v path="$1" '$2 ~ ("^" path) { print $2 }' /proc/self/mounts | sort -r | xargs -r -t -n 1 umount
}
do_unmount '/run/k3s'

View File

@ -546,18 +546,7 @@ getshims() {
killtree $({ set +x; } 2>/dev/null; getshims; set -x)
do_unmount() {
{ set +x; } 2>/dev/null
MOUNTS=
while read ignore mount ignore; do
MOUNTS="$mount\n$MOUNTS"
done </proc/self/mounts
MOUNTS=$(printf $MOUNTS | grep "^$1" | sort -r)
if [ -n "${MOUNTS}" ]; then
set -x
xargs -n 1 umount <<< ${MOUNTS}
else
set -x
fi
awk -v path="$1" '$2 ~ ("^" path) { print $2 }' /proc/self/mounts | sort -r | xargs -r -t -n 1 umount
}
do_unmount '/run/k3s'