return code checking in install_rally.sh doesn't work

Bug #1463468 reported by Albert White
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Rally
Fix Released
Medium
Albert White

Bug Description

in install_rally.sh we do

set -e
...
args=$(getopt --name "$PROG" --shell sh -l "$long_opts" -o "$short_opts" -- "$@")
    if [ $? -ne 0 ]; then
...

set -e instructs the shell to exit when a command returns a non zero error code so if getopt fails we never make it into the if conditions to proceed.

A solution is to allow shell commands to give non zero return codes around this piece of code:

diff --git a/install_rally.sh b/install_rally.sh
index 1f15fd3..d606d4c 100755
--- a/install_rally.sh
+++ b/install_rally.sh
@@ -460,6 +460,7 @@ setup_rally_configuration () {
 short_opts='d:vfsyhD:p:'
 long_opts='target:,verbose,overwrite,system,yes,dbtype:,python:,db-user:,db-password:,db-host:,db-name:,help'

+set +e
 if [ "x$(getopt -T)" = 'x' ]; then
     # GNU getopt
     args=$(getopt --name "$PROG" --shell sh -l "$long_opts" -o "$short_opts" -- "$@")
@@ -472,10 +473,11 @@ else
     # old-style getopt, use compatibility syntax
     args=$(getopt "$short_opts" "$@")
     if [ $? -ne 0 ]; then
- abort 1 "Type '$PROG --help' to get usage information."
+ abort 1 "Type '$PROG -h' to get usage information."
     fi
     eval set -- "$args"
 fi
+set -e

 # Command line parsing
 while true

Albert White (albertw)
Changed in rally:
assignee: nobody → Albert White (albertw)
Albert White (albertw)
description: updated
Albert White (albertw)
Changed in rally:
status: New → In Progress
Changed in rally:
importance: Undecided → Medium
milestone: none → 0.1.0
Changed in rally:
status: In Progress → Fix Committed
Changed in rally:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.