bin/b: fix sudo prompt for paths with spaces

This commit is contained in:
xeruf 2021-10-12 08:42:22 +02:00
parent 653526346f
commit b73a5d7e37
1 changed files with 4 additions and 2 deletions

View File

@ -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