diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-01-30 08:36:08 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-01-30 08:36:08 +0000 |
commit | adcdd7185bced7de061e9fe15b5f7d1f17610cff (patch) | |
tree | c6832b9462adc82b77e4252ba87ae35620aee4aa /kiss | |
parent | 9ddd4101dd985e3460ea02edeaa3c414a53589b1 (diff) | |
download | cpt-adcdd7185bced7de061e9fe15b5f7d1f17610cff.tar.gz |
kiss: Allow option of setting sudo command
FossilOrigin-Name: 4a7d8200bf7def9eba537edb2501a6d0079df6be1e5ee2c92eff0463dfd886b6
Diffstat (limited to 'kiss')
-rwxr-xr-x | kiss | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -50,14 +50,13 @@ prompt() { as_root() { [ "$(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 - exec 3<&0 - su -pc "KISS_FORCE=$KISS_FORCE $* <&3" </dev/tty - fi + log "Using '${su:-su}'" + + case $su in + *sudo) sudo -E KISS_FORCE="$KISS_FORCE" "$@" ;; + *doas) KISS_FORCE="$KISS_FORCE" doas "$@" ;; + *) su -pc "KISS_FORCE=$KISS_FORCE $* <&3" 3<&0 </dev/tty ;; + esac exit } @@ -1318,6 +1317,10 @@ main() { # POSIX correctness. grep=$(command -v ggrep) || grep='grep' + # Figure out which 'sudo' command to use based on the user's choice or + # what is available on the system. + su=${KISS_SU:-$(command -v sudo || command -v doas)} || su=su + # Store the date and time of script invocation to be used as the name # of the log files the package manager creates uring builds. time=$(date '+%d-%m-%Y-%H:%M') |