From 849430b2ce02411bf94c1b0b2d1068a60dd0a7fc Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Sun, 23 Oct 2016 23:35:59 +0100
Subject: [PATCH] Capture return code

---
 src/freedombone-controlpanel | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel
index a8b97dd6b..8ca29553b 100755
--- a/src/freedombone-controlpanel
+++ b/src/freedombone-controlpanel
@@ -960,13 +960,14 @@ function restore_data_from_storage {
             app_name=${app_list[app_index]}
             if [[ $app_name == "$AllStr" ]]; then
                 $restore_command
-                if [ ! "$?" = "0" ]; then
+                retcode="$?"
+                if [[ "$retcode" != "0" ]]; then
                     if [[ "$1" == "local" ]]; then
                         dialog --title $"Restore all apps from USB" \
-                               --msgbox $"Restore failed with code $?" 6 40
+                               --msgbox $"Restore failed with code $retcode" 6 40
                     else
                         dialog --title $"Restore all apps from $1" \
-                               --msgbox $"Restore failed with code $?" 6 40
+                               --msgbox $"Restore failed with code $retcode" 6 40
                     fi
                     return
                 fi
@@ -989,9 +990,10 @@ function restore_data_from_storage {
             app_name=${app_list[app_index]}
             if [ ${#app_name} -gt 0 ]; then
                 $restore_command "${app_name}"
-                if [ ! "$?" = "0" ]; then
+                retcode="$?"
+                if [[ "$retcode" != "0" ]]; then
                     dialog --title $"Restore apps from USB" \
-                           --msgbox $"Restore of ${app_name} failed with code $?" 6 40
+                           --msgbox $"Restore of ${app_name} failed with code $retcode" 6 40
                     return
                 fi
             fi
-- 
GitLab