[neon/neon/settings/Neon/release] usr/lib/neon_update: make logic easier on the eyes
Harald Sitter
null at kde.org
Mon Jun 14 14:48:47 BST 2021
Git commit b3eda5d4c079c39168d316aafbf8399e41376e52 by Harald Sitter.
Committed on 14/06/2021 at 13:41.
Pushed by sitter into branch 'Neon/release'.
make logic easier on the eyes
all the $ret stuff gave me a right headache and int bools also don't
help. so, use stringy bool named skip instead.
also explain why password prompting logic is the way it is
M +12 -7 usr/lib/neon_update/neon_offline_skip.sh
https://invent.kde.org/neon/neon/settings/commit/b3eda5d4c079c39168d316aafbf8399e41376e52
diff --git a/usr/lib/neon_update/neon_offline_skip.sh b/usr/lib/neon_update/neon_offline_skip.sh
index e330844..37c9e53 100755
--- a/usr/lib/neon_update/neon_offline_skip.sh
+++ b/usr/lib/neon_update/neon_offline_skip.sh
@@ -2,27 +2,32 @@
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
# SPDX-FileCopyrightText: 2021 Harald Sitter <sitter at kde.org>
-ret=0
+skip="no"
if plymouth --ping; then
TXT0="Preparing system update..."
TXT1="keys:press 'c' to cancel" # keys: is a special behavior hack we have in breeze-plymouth, putting it in a special label
plymouth display-message --text="$TXT0"
plymouth display-message --text="$TXT1"
timeout -s KILL 10s plymouth watch-keystroke --keys="cC"
- ret=$?
+ if [ "$?" != "0" ]; then # timeout=1, keystroke=0
+ skip="yes"
+ fi
plymouth hide-message --text="$TXT1"
else
- # prompting without plymouth is hella horrible, abuse systemd's password helper as stand-in for plymouth
+ # prompting without plymouth is hella horrible, abuse systemd's password helper as stand-in for plymouth.
+ # Unlike plymouth we need to check the input in some form or fashion though
out=$(systemd-ask-password --echo --timeout=10 "Enter 'c' and hit enter to cancel system update...")
- ret=$?
- if [ "$out" != "" ]; then
+ if [ "$out" = "" ]; then
# we do not actually care greatly about the input so long as it is not empty. hitting enter isn't really
# indicative of anything. could mean go away, could mean hurry up. who's to say.
- ret=0
+ # $out consequently ought only be empty if the timeout was hit or the user hit enter without input
+ skip="no"
+ else
+ skip="yes"
fi
fi
-if [ "$ret" != "0" ]; then
+if [ "$skip" = "yes" ]; then
echo "Continuing with update"
exit 0
fi
More information about the Neon-commits
mailing list