#1454 PR merged
: Simplified UserInput return codes to the 'read' return code¶
Labels: cleanup
, fixed / solved / done
jsmeix opened issue at 2017-08-24 17:53:¶
The UserInput return code is now simply 0 or 1:
The UserInput return code is the return code of
the 'read' bash builtin that is called to get user input.
When the UserInput function is called with right syntax
its return code is 0 for any actual user input and
in case of any (non empty) automated user input.
The return code is 1 when the 'read' call timed out
(i.e. when there was no actual user input)
so that one can distinguish between an explicitly
provided user input and no actual user input
even if the explicitly provided user input is the same
as the default so that it makes a difference
whether or not the user explicitly chose and confirmed
that the default is what he actually wants
or if he let things "just happen" inattentively via timeout
where it is important to have a big timeout
so that an attentive user will actively provide user input
to proceed even if it is same as the default.
Cf.
https://github.com/rear/rear/pull/1449#issuecomment-324401086
The UserInput function logged already
whether or not its 'read' call timed out
but its various return codes were oversophisticated.
Now the UserInput function return code has a simple meaning:
0 means "real input" while 1 means "fallback/default".
Now in caller scipts code like
if input="$( UserInput ... )" ; then LogPrint "Got $input" else LogPrint "Using default $input" fi
can be used if different behaviour is intended depending
on "real input" versus fallback/default behaviour.
jsmeix commented at 2017-08-25 11:21:¶
@schlomo
I have the "Avoid stderr ..." comments explicitly because of your
https://github.com/rear/rear/issues/1395#issuecomment-311678896
to show why in this case ReaR does rightfully destroy information
(here misleading information about possibly wrong bash coding).
Via
https://github.com/rear/rear/issues/1395
I planned to clean up all '>/dev/null' usage in ReaR
(in particular both '1>/dev/null' and '2>/dev/null')
but until I have done this (which needs some time)
I need comments where a '>/dev/null' usage
is really right in ReaR.
[Export of Github issue for rear/rear.]