From 224417ec8f75e516d115c9912f1fadf856cb0271 Mon Sep 17 00:00:00 2001 From: appeasementPolitik <108810900+appeasementPolitik@users.noreply.github.com> Date: Sun, 12 Feb 2023 12:04:33 +0000 Subject: [PATCH] Shellcheck --- .local/bin/unmounter | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/unmounter b/.local/bin/unmounter index 67e9263f..57f14ec6 100755 --- a/.local/bin/unmounter +++ b/.local/bin/unmounter @@ -32,8 +32,8 @@ test -b /dev/mapper/"${cryptid##*/}" && mntline=$(echo "$lsblkoutput" | tac | grep -m1 -n "/${chosen#*/}" | cut -d':' -f1) [ -n "$mntline" ] && devlabel=$(echo "$lsblkoutput" | tac | tail -n +"$mntline" | grep -m1 '[^ ]* disk' | cut -d'/' -f3 | cut -d' ' -f1) && - samedrivemounts=$(echo "$lsblkoutput" | tac | awk '$1~/'"$devlabel"'/&&!cnt{cnt=1}cnt{if($2~/disk/||cnt>2){cnt-=1;print cnt;exit}if($4){cnt+=1}}') && + samedrivemounts=$(echo "$lsblkoutput" | tac | awk '!cnt&&$1~/'"$devlabel"'/{cnt=1}cnt{if(cnt>2||$2~/disk/){cnt-=1;print cnt;exit}if($4){cnt+=1}}') && [ "$samedrivemounts" = 1 ] && - [ $(printf "No\nYes" | dmenu -p 'Device fully unmounted. Eject this drive?') == 'Yes' ] && + [ "$(printf "No\nYes" | dmenu -p 'Device fully unmounted. Eject this drive?')" = 'Yes' ] && sudo -A sh -c "echo offline > /sys/block/$devlabel/device/state; echo 1 > /sys/block/$devlabel/device/delete" && notify-send "Device ejected." "Drive can now be removed safely."