[hamradio-commits] [dump1090-mutability] 36/172: Rearrange validation so that the user only ever sees errors *after* providing input.
Matteo F. Vescovi
mfv at moszumanska.debian.org
Sun Jan 28 13:45:44 UTC 2018
This is an automated email from the git hooks/post-receive script.
mfv pushed a commit to branch master
in repository dump1090-mutability.
commit 01c4bee566f8c3fd09d5a2c816423dbfc8894a62
Author: Oliver Jowett <oliver at mutability.co.uk>
Date: Wed Dec 10 21:20:31 2014 +0000
Rearrange validation so that the user only ever sees errors
*after* providing input.
In particular if the existing config does not validate then we
should just ensure that the problematic question is displayed
without a confusing error message beforehand; the error should
only appear if the newly entered response doesn't validate.
---
debian/dump1090-mutability.config | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/debian/dump1090-mutability.config b/debian/dump1090-mutability.config
index 74e49fe..48df016 100644
--- a/debian/dump1090-mutability.config
+++ b/debian/dump1090-mutability.config
@@ -62,28 +62,32 @@ db_input_verify() {
db_input $PRI $KEY; RESULT=$?
db_go
set -e
+ ASKED=0
while :
do
db_get $KEY
if $VERIFY $RET; then return 0; fi
if [ $RESULT -ne 0 ]; then
# db_input failed, and the existing value does not validate
- if [ $RESULT = 30 ] && [ $PRI != high ]
+ if [ $RESULT = 30 ] && [ $ASKED = 0 ]
then
- # question wasn't displayed, but existing value is invalid
- # bump priority and try again
- PRI=high
+ # question was skipped, but existing value is invalid
+ # bump priority and try again (once)
+ PRI=high
+ ASKED=1
else
# give up, use the default value
db_reset $KEY
return 0
fi
+ else
+ # db_input was OK, but the value did not verify.
+ # show an error message
+ db_input high dump1090-mutability/invalid-$VERIFY || true
fi
- # db_input was OK, but the value did not verify.
- # display an error and try again.
+ # try again
set +e
- db_input high dump1090-mutability/invalid-$VERIFY
db_fset $KEY seen false
db_input high $KEY; RESULT=$?
db_go
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090-mutability.git
More information about the pkg-hamradio-commits
mailing list