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.
This commit is contained in:
parent
3af0fb51b5
commit
1cdfe8db27
16
debian/dump1090-mutability.config
vendored
16
debian/dump1090-mutability.config
vendored
|
@ -62,28 +62,32 @@ db_input_verify() {
|
||||||
db_input $PRI $KEY; RESULT=$?
|
db_input $PRI $KEY; RESULT=$?
|
||||||
db_go
|
db_go
|
||||||
set -e
|
set -e
|
||||||
|
ASKED=0
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
db_get $KEY
|
db_get $KEY
|
||||||
if $VERIFY $RET; then return 0; fi
|
if $VERIFY $RET; then return 0; fi
|
||||||
if [ $RESULT -ne 0 ]; then
|
if [ $RESULT -ne 0 ]; then
|
||||||
# db_input failed, and the existing value does not validate
|
# db_input failed, and the existing value does not validate
|
||||||
if [ $RESULT = 30 ] && [ $PRI != high ]
|
if [ $RESULT = 30 ] && [ $ASKED = 0 ]
|
||||||
then
|
then
|
||||||
# question wasn't displayed, but existing value is invalid
|
# question was skipped, but existing value is invalid
|
||||||
# bump priority and try again
|
# bump priority and try again (once)
|
||||||
PRI=high
|
PRI=high
|
||||||
|
ASKED=1
|
||||||
else
|
else
|
||||||
# give up, use the default value
|
# give up, use the default value
|
||||||
db_reset $KEY
|
db_reset $KEY
|
||||||
return 0
|
return 0
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
# db_input was OK, but the value did not verify.
|
# try again
|
||||||
# display an error and try again.
|
|
||||||
set +e
|
set +e
|
||||||
db_input high dump1090-mutability/invalid-$VERIFY
|
|
||||||
db_fset $KEY seen false
|
db_fset $KEY seen false
|
||||||
db_input high $KEY; RESULT=$?
|
db_input high $KEY; RESULT=$?
|
||||||
db_go
|
db_go
|
||||||
|
|
Loading…
Reference in a new issue