Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed exit in usr/sbin/rear when getopt failed #2022

Merged
merged 1 commit into from Jan 23, 2019

Conversation

jsmeix
Copy link
Member

@jsmeix jsmeix commented Jan 22, 2019

  • 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
#2013 (comment)

@jsmeix jsmeix added the bug The code does not do what it is meant to do label Jan 22, 2019
@jsmeix jsmeix added this to the ReaR v2.5 milestone Jan 22, 2019
@jsmeix jsmeix self-assigned this Jan 22, 2019
@jsmeix jsmeix requested a review from a team January 22, 2019 15:03
@jsmeix
Copy link
Member Author

jsmeix commented Jan 22, 2019

If there are no (furious ;-) objections
I would like to merge it tomorrow afternoon.

@jsmeix jsmeix merged commit 4df6b61 into rear:master Jan 23, 2019
@jsmeix jsmeix deleted the fix_exit_in_sbin_rear_when_getopt_failed branch January 23, 2019 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The code does not do what it is meant to do fixed / solved / done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant