From 5b2e202b4f77490b8a0e152aac8bc5042a9d5e20 Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:13:27 -0500 Subject: [PATCH] Fix try_exec failure detection --- lug-helper.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index 97aa9ec..eb8d9e7 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -245,16 +245,18 @@ try_exec() { if [ -x "$(command -v pkexec)" ]; then pkexec sh -c "$1" - # Check the return value - if [ "$?" -eq 126 ] || [ "$?" -eq 127 ]; then + # Check the exit status + statuscode="$?" + if [ "$statuscode" -eq 126 ] || [ "$statuscode" -eq 127 ]; then # User cancel or error retval=1 fi else sudo sh -c "$1" - # Check the return value - if [ "$?" -eq 1 ]; then + # Check the exit status + statuscode="$?" + if [ "$statuscode" -eq 1 ] || [ "$statuscode" -eq 127 ]; then # Error retval=1 fi