diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-01-30 07:50:17 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-01-30 07:50:17 +0000 |
commit | 61647abe7e0b7a26eb4db06ea13f78ee9bc71f5c (patch) | |
tree | a024e770b9421cbc46de673ebb8b5644f6ba1a58 /kiss | |
parent | 95272845a5b7e3e677e09fe2b8428a842b783249 (diff) | |
download | cpt-61647abe7e0b7a26eb4db06ea13f78ee9bc71f5c.tar.gz |
kiss: as_root: Move to func
FossilOrigin-Name: 48264c5ea24e824e4c77bb405191f13ef4f072528817ad328445068ec3ac2fb2
Diffstat (limited to 'kiss')
-rwxr-xr-x | kiss | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -49,13 +49,17 @@ prompt() { } as_root() { - if command -v sudo >/dev/null; then - sudo -E KISS_FORCE="$KISS_FORCE" "$@" - elif command -v doas >/dev/null; then - KISS_FORCE="$KISS_FORCE" doas "$@" - else - su -pc "KISS_FORCE=$KISS_FORCE $*" - fi + [ "$(id -u)" = 0 ] || { + if command -v sudo >/dev/null; then + sudo -E KISS_FORCE="$KISS_FORCE" "$@" + elif command -v doas >/dev/null; then + KISS_FORCE="$KISS_FORCE" doas "$@" + else + su -pc "KISS_FORCE=$KISS_FORCE $*" + fi + + exit + } } regex_escape() { @@ -1153,10 +1157,7 @@ args() { a|alternatives) # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. - [ -z "$1" ] || [ "$(id -u)" = 0 ] || { - as_root kiss "$action" "$@" - return - } + [ -z "$1" ] || as_root kiss "$action" "$@" ;; i|install|r|remove) @@ -1164,10 +1165,7 @@ args() { # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. - [ "$(id -u)" = 0 ] || { - as_root kiss "$action" "$@" - return - } + as_root kiss "$action" "$@" ;; esac |