Whamcloud - gitweb
LU-10505 scripts: avoid version dependent shell script syntax 60/30860/3
authorBob Glossman <bob.glossman@intel.com>
Fri, 12 Jan 2018 21:51:26 +0000 (13:51 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 25 Jan 2018 04:47:53 +0000 (04:47 +0000)
Stop using -1 as an array index in lfs_migrate.
This isn't a valid construct in all supported bash versions.

Test-Parameters: trivial clientdistro=el6.9

Change-Id: I5500af40926e0fdb2a432c6bae7fbbe05097ec7c
Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-on: https://review.whamcloud.com/30860
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/scripts/lfs_migrate

index 6abc0e3..c598f06 100755 (executable)
@@ -122,6 +122,7 @@ for f in $(seq 1 $#); do
                else
                        LONG_OPT=true
                        OPT_PASSTHROUGH+=("$arg")
+                       PREV="$arg"
                fi
        elif [ "${arg:0:1}" = "-" ]; then
                LONG_OPT=false
@@ -130,6 +131,7 @@ for f in $(seq 1 $#); do
                else
                        SHORT_OPT=true
                        OPTS+=("$arg")
+                       PREV="$arg"
                fi
        elif $LONG_OPT; then
                LONG_OPT=false
@@ -138,20 +140,20 @@ for f in $(seq 1 $#); do
                if [ -f "$arg" -o -d "$arg" ]; then
                        OPTS+=("$arg")
                else
-                       [ "${OPT_PASSTHROUGH[-1]}" = "--stripe-count" ] &&
+                       [ "$PREV" = "--stripe-count" ] &&
                                STRIPE_COUNT="$arg"
-                       [ "${OPT_PASSTHROUGH[-1]}" = "--stripe-size" ] &&
+                       [ "$PREV" = "--stripe-size" ] &&
                                STRIPE_SIZE="$arg"
-                       [ "${OPT_PASSTHROUGH[-1]}" = "--pool" ] &&
+                       [ "$PREV" = "--pool" ] &&
                                POOL="$arg"
                        OPT_PASSTHROUGH+=("$arg")
                fi
        elif $SHORT_OPT; then
-               [ "${OPTS[-1]}" = "-c" ] &&
+               [ "$PREV" = "-c" ] &&
                        STRIPE_COUNT="$arg"
-               [ "${OPTS[-1]}" = "-S" ] &&
+               [ "$PREV" = "-S" ] &&
                        STRIPE_SIZE="$arg"
-               [ "${OPTS[-1]}" = "-p" ] &&
+               [ "$PREV" = "-p" ] &&
                        POOL="$arg"
                SHORT_OPT=false
                OPTS+=("$arg")