bin: little elevation fix

This commit is contained in:
xeruf 2021-11-02 12:00:43 +00:00
parent d0e8310c94
commit 620b628ba5
2 changed files with 1 additions and 2 deletions

View File

@ -1,5 +1,4 @@
#!/bin/sh #!/bin/sh
# interactive diff with pagination and nice coloring # interactive diff with pagination and nice coloring
set -o pipefail
diff-color --report-identical-files "$@" | diff-color --report-identical-files "$@" |
less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen

View File

@ -3,7 +3,7 @@
# and moves the preceding arguments into it. # and moves the preceding arguments into it.
# Automatically elevates if missing permissions. # Automatically elevates if missing permissions.
for last; do true; done for last; do true; done
! test -e "$1" && echo "$1 does not exist" && exit 1
checkaccess -w "$@" || elevate=sudo checkaccess -w "$@" || elevate=sudo
! $elevate test -e "$1" && echo "$1 does not exist" && exit 1
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) $elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)
$elevate mv --interactive "$@" $elevate mv --interactive "$@"