From b73a5d7e37c6eee5ad5366dacb0588195d5708b2 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 12 Oct 2021 08:42:22 +0200 Subject: [PATCH] bin/b: fix sudo prompt for paths with spaces --- .local/bin/scripts/b | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 7eb34cb..3ec0ca9 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -7,8 +7,10 @@ set -eo pipefail for last; do true; done last=${last:-.} -# Elevate permissions if the file exists but is not accessible -test -x "$(dirname $last)" && { test -r "$last" || ! test -e "$last"; } || elevate=sudo +# Elevate permissions if the file is not accessible +test -x "$(dirname "$last")" && + { test -r "$last" || ! test -e "$last"; } || + elevate=sudo tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$' || true ) case "$($elevate file --dereference --mime "$last")" in