aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-30 12:42:29 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-30 12:42:29 +0000
commit56de7dd25aa31cf00d15fb5496127693c8f31e15 (patch)
treef29466fa2bce8b31d522a2fc0f340c979c312f56 /kiss
parentd5d050c705db977279c315ad99fc7c67be872222 (diff)
downloadcpt-56de7dd25aa31cf00d15fb5496127693c8f31e15.tar.gz
kiss: Fix update issue
FossilOrigin-Name: b9d50e94e10e86232e5eb751fdf901be2c51529f29028278eb4b146a9b7f73a6
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss33
1 files changed, 17 insertions, 16 deletions
diff --git a/kiss b/kiss
index 3b474f5..fea22a0 100755
--- a/kiss
+++ b/kiss
@@ -51,22 +51,17 @@ 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}'"
+ log "Using '${su:-su}'"
- # doas requires these environment variables to be set as they
- # aren't brought over from the calling user.
- env="HOME='$HOME' KISS_FORCE='$KISS_FORCE' KISS_PATH='$KISS_PATH'"
+ # doas requires these environment variables to be set as they
+ # aren't brought over from the calling user.
+ env="HOME='$HOME' KISS_FORCE='$KISS_FORCE' KISS_PATH='$KISS_PATH'"
- case $su in
- *sudo) sudo -E sh -c "$*" ;;
- *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
- }
+ case $su in
+ *sudo) sudo -E sh -c "$*" ;;
+ *doas) doas -- sh -c "$env $*" ;;
+ *) su -pc "$* <&3" 3<&0 </dev/tty ;;
+ esac
}
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.
- KISS_FORCE="$KISS_FORCE" as_root kiss "$action" "$@"
+ [ "$(id -u)" = 0 ] || {
+ KISS_FORCE="$KISS_FORCE" as_root kiss "$action" "$@"
+ return
+ }
;;
esac