Previously we used a ugly hack to extract the device from the whole
line returned by passing it to bash's `set`, which assigns remaining
arguments it does not know about (or after "--") to $1, $2, etc.
This is ugly due to:
* not using "--", so it could break easily
* being quite subtle in general, e.g., shellcheck does not likes
unquoted variable expansions, so one would add quotes around
breaking the actual use case
Just use awk to do both the grep and extraction, which is much
clearer to do
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
/etc/init.d/udev stop
echo -n "Deactivating swap..."
- swap=$(grep /dev /proc/swaps);
+ swap=$(awk '/^\/dev\// { print $1 }' /proc/swaps);
if [ -n "$swap" ]; then
- set $swap
- swapoff $1
+ swapoff "$swap"
fi
echo "done."