Selaa lähdekoodia

Menu style for setting trust level

Bob Mottram 7 vuotta sitten
vanhempi
commit
df1961e553
1 muutettua tiedostoa jossa 18 lisäystä ja 27 poistoa
  1. 18
    27
      src/freedombone-controlpanel-user

+ 18
- 27
src/freedombone-controlpanel-user Näytä tiedosto

@@ -283,34 +283,25 @@ function gpg_set_trust {
283 283
     fpr=$(gpg --with-colons --fingerprint "$TRUST_ADDRESS" | grep fpr | head -n 1 | awk -F ':' '{print $10}')
284 284
     if [ ${#fpr} -gt 2 ]; then
285 285
 
286
-        data=$(mktemp 2>/dev/null)
287
-        dialog --backtitle $"Freedombone User Control Panel" \
288
-               --title $"Trust a PGP/GPG key or website domain" \
289
-               --radiolist $"Set the trust level for $TRUST_ADDRESS:" 18 70 10 \
290
-               1 $"I don't know or won't say" off \
291
-               2 $"I do NOT trust" off \
292
-               3 $"I trust marginally" on \
293
-               4 $"I trust fully" off \
294
-               5 $"I trust ultimately" off 2> "$data"
295
-        sel=$?
296
-        case $sel in
297
-            1) rm -f "$data"
298
-               return;;
299
-            255) rm -f "$data"
300
-                 return;;
301
-        esac
302
-        TRUST_LEVEL=$(cat "$data")
303
-        if [ "${TRUST_LEVEL}" -ge 1 ] ; then
304
-            if [ "${TRUST_LEVEL}" -le 5 ] ; then
305
-                if echo -e "trust\\n${TRUST_LEVEL}\\ny\\nsave\\n" | gpg --command-fd 0 --edit-key "$fpr"; then
306
-                    gpg --update-trustdb
307
-                    dialog --title $"Trust a PGP/GPG key or website domain" \
308
-                           --backtitle $"Freedombone User Control Panel" \
309
-                           --msgbox $"$TRUST_ADDRESS was set to trust level ${TRUST_LEVEL}" 6 50
310
-                fi
311
-            fi
286
+        W=(1 $"I don't know or won't say"
287
+           2 $"I do NOT trust"
288
+           3 $"I trust marginally"
289
+           4 $"I trust fully"
290
+           5 $"I trust ultimately")
291
+
292
+        # shellcheck disable=SC2068
293
+        TRUST_LEVEL=$(dialog --backtitle $"Freedombone User Control Panel" --title $"Trust a PGP/GPG key or website domain" --menu $"Set the trust level for $TRUST_ADDRESS:" 18 70 10 "${W[@]}" 3>&2 2>&1 1>&3)
294
+
295
+        if [ ! "$TRUST_LEVEL" ]; then
296
+            return;
297
+        fi
298
+
299
+        if echo -e "trust\\n${TRUST_LEVEL}\\ny\\nsave\\n" | gpg --command-fd 0 --edit-key "$fpr"; then
300
+            gpg --update-trustdb
301
+            dialog --title $"Trust a PGP/GPG key or website domain" \
302
+                   --backtitle $"Freedombone User Control Panel" \
303
+                   --msgbox $"$TRUST_ADDRESS was set to trust level ${TRUST_LEVEL}" 6 50
312 304
         fi
313
-        rm -f "$data"
314 305
     fi
315 306
 }
316 307