From 7493ccb17beb5803c535772ec2315f64448b63e7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 27 Jan 2020 11:24:58 +0200 Subject: [PATCH] kiss: Only cache root on first need --- kiss | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/kiss b/kiss index cb6753c..5107ff7 100755 --- a/kiss +++ b/kiss @@ -54,9 +54,9 @@ root_cache() { # permissions where needed without the endless stream of # password prompts. printf 'Password: ' - stty -echo - read -r pass || read -r pass ||: - stty echo + stty -F /dev/tty -echo + read -r pass /dev/null + stty -F /dev/tty echo 2>/dev/null [ "$KISS_DEBUG" != 1 ] || return @@ -1017,17 +1017,9 @@ args() { # Parse some arguments earlier to remove the need to duplicate code. case $action in - c|checksum|s|search) + c|checksum|s|search|i|install|r|remove) [ "$1" ] || die "'kiss $action' requires an argument" ;; - - i|install|r|remove|u|update) - [ "$1" ] || [ -z "${action##u*}" ] || - die "'kiss $action' requires an argument" - - # Cache the root password for use where needed. - [ "$(id -u)" = 0 ] || root_cache - ;; esac # Actions can be abbreviated to their first letter. This saves