1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-25 16:40:07 -07:00

kiss: Fix update issue

This commit is contained in:
Dylan Araps 2020-01-30 14:42:29 +02:00
parent ca26070683
commit 0a64dc1808
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

13
kiss
View File

@ -51,7 +51,6 @@ prompt() {
as_root() {
# Simple function to run a command as root using either 'sudo',
# 'doas' or 'su'. This also handles KISS' environment variables.
[ "$(id -u)" = 0 ] || {
log "Using '${su:-su}'"
# doas requires these environment variables to be set as they
@ -63,10 +62,6 @@ as_root() {
*doas) doas -- sh -c "$env $*" ;;
*) su -pc "$* <&3" 3<&0 </dev/tty ;;
esac
# Only exit here if we're spawning a second 'kiss' instance.
[ "$1" != kiss ] || exit
}
}
regex_escape() {
@ -1145,7 +1140,10 @@ 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" ] || as_root kiss "$action" "$@"
[ -z "$1" ] || [ "$(id -u)" = 0 ] || {
as_root kiss "$action" "$@"
return
}
;;
i|install|r|remove)
@ -1153,7 +1151,10 @@ 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 ] || {
KISS_FORCE="$KISS_FORCE" as_root kiss "$action" "$@"
return
}
;;
esac