#2022 PR merged
: Fixed exit in usr/sbin/rear when getopt failed¶
Labels: bug
, fixed / solved / done
jsmeix opened issue at 2019-01-22 15:03:¶
-
Type: Bug Fix
-
Impact: Normal
-
How was this pull request tested?
By me on my openSUSE Leap 15.0 system.
Before:
# usr/sbin/rear -Q dump
rear: invalid option -- 'Q'
# Begin dumping out configuration and system information:
...
(i.e. the 'dump' workflow is run).
With the fix here:
# usr/sbin/rear -Q dump
rear: invalid option -- 'Q'
Use 'rear --help' or 'man rear' for more information.
- Brief description of the changes in this pull request:
In the code before in usr/sbin/rear
readonly OPTS="$( getopt -n $PROGRAM -o "c:C:dDhsSvVr:" -l "help,version,debugscripts:" -- "$@" )"
if test $? -ne 0 ; then
echo "$help_note_text"
exit 1
fi
the $?
does not contain the getopt
exit code
but the readonly
return code which is always zero.
The new code
if ! OPTS="$( getopt -n $PROGRAM -o "c:C:dDhsSvVr:" -l "help,version,debugscripts:" -- "$@" )" ; then
echo "$help_note_text"
exit 1
fi
readonly OPTS
fixes that.
In general using $?
is problematic, cf. the StopIf...
functions
https://github.com/rear/rear/pull/2013#discussion_r245909346
jsmeix commented at 2019-01-22 15:33:¶
If there are no (furious ;-) objections
I would like to merge it tomorrow afternoon.
[Export of Github issue for rear/rear.]