Wait for user input if run_elevated fails

* This is a workaround for su/sudo timeouts
* Should help with issue #17
This commit is contained in:
2Shirt 2018-02-28 13:32:45 -07:00
parent d82ad55113
commit 51f9f91195

View file

@ -32,7 +32,7 @@ fi
function ask() {
while :; do
read -p "$1 " -r answer
read -p "$1 [Y/N] " -r answer
if echo "$answer" | egrep -iq '^(y|yes|sure)$'; then
return 0
elif echo "$answer" | egrep -iq '^(n|no|nope)$'; then
@ -122,11 +122,21 @@ function run_elevated() {
prog="$1"
shift
if which sudo >/dev/null 2>&1; then
if ! sudo "$prog" $*; then
echo "ERROR: Failed to run '$prog'"
if ask "Retry?"; then
sudo "$prog" $*
fi
fi
else
echo -n "Root "
if ! su -c "export REAL_USER=$USER && '$prog' $*"; then
echo "ERROR: Failed to run '$prog'"
if ask "Retry?"; then
su -c "export REAL_USER=$USER && '$prog' $*"
fi
fi
fi
}
function update_live_env() {