aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-30 12:32:57 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-30 12:32:57 +0000
commitd5d050c705db977279c315ad99fc7c67be872222 (patch)
treebf21d04a72e7979e0e1bc179f6b69271eabd2330
parenta9f46c04eda31e99815a4217c7706db7dfbb4b06 (diff)
downloadcpt-d5d050c705db977279c315ad99fc7c67be872222.tar.gz
kiss: Fix update bug
FossilOrigin-Name: a273f86d1a17a2f0f82a9ec0f38d03336fda390386e0167ac3f9c8515d5a1a20
-rwxr-xr-xkiss13
1 files changed, 10 insertions, 3 deletions
diff --git a/kiss b/kiss
index c335a9b..3b474f5 100755
--- a/kiss
+++ b/kiss
@@ -49,16 +49,23 @@ 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
+ # 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 "HOME='$HOME' KISS_PATH='$KISS_PATH' $*" ;;
+ *doas) doas -- sh -c "$env $*" ;;
*) su -pc "$* <&3" 3<&0 </dev/tty ;;
esac
- exit
+ # Only exit here if we're spawning a second 'kiss' instance.
+ [ "$1" != kiss ] || exit
}
}
@@ -1255,7 +1262,7 @@ args() {
;;
v|version|-v|--version)
- log kiss 1.1.3
+ log kiss 1.1.4
;;
h|help|-h|--help|'')