From: Bob Glossman Date: Fri, 12 Jan 2018 21:51:26 +0000 (-0800) Subject: LU-10505 scripts: avoid version dependent shell script syntax X-Git-Tag: 2.10.58~51 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F30860%2F3;p=fs%2Flustre-release.git LU-10505 scripts: avoid version dependent shell script syntax 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 Reviewed-on: https://review.whamcloud.com/30860 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: James Nunez Reviewed-by: Oleg Drokin --- diff --git a/lustre/scripts/lfs_migrate b/lustre/scripts/lfs_migrate index 6abc0e3..c598f06 100755 --- a/lustre/scripts/lfs_migrate +++ b/lustre/scripts/lfs_migrate @@ -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")