+OPT_CHECK=true
+OPT_DEBUG=false
+OPT_NO_RSYNC=false
+OPT_DRYRUN=false
+OPT_YES=false
+OPT_RESTRIPE=false
+OPT_NULL=false
+OPT_PASSTHROUGH=()
+STRIPE_COUNT=""
+STRIPE_SIZE=""
+POOL=""
+
+# Examine any long options and arguments. getopts does not support long
+# options, so they must be stripped out and classified as either options
+# for the script, or passed through to "lfs migrate".
+LONG_OPT=false
+SHORT_OPT=false
+OPTS=()
+
+for f in $(seq 1 $#); do
+ arg=${!f}
+ if [ "${arg:0:2}" = "--" ]; then
+ SHORT_OPT=false
+ if [ "$arg" = "--block" ]; then
+ BLOCK="$arg"
+ OPT_YES=true
+ elif [ "$arg" = "--non-block" ]; then
+ BLOCK="$arg"
+ elif [ "$arg" = "--dry-run" ]; then
+ OPT_DRYRUN=true
+ OPT_YES=true
+ elif [ "$arg" = "--rsync" ]; then
+ LFS_MIGRATE_RSYNC_MODE=true
+ elif [ "$arg" = "--no-rsync" ]; then
+ OPT_NO_RSYNC=true
+ OPT_YES=true
+ else
+ LONG_OPT=true
+ OPT_PASSTHROUGH+=("$arg")
+ fi
+ elif [ "${arg:0:1}" = "-" ]; then
+ LONG_OPT=false
+ if [ "$arg" == "-b" ]; then
+ BLOCK="$arg"
+ else
+ SHORT_OPT=true
+ OPTS+=("$arg")
+ fi
+ elif $LONG_OPT; then
+ LONG_OPT=false
+ # This will prevent long options from having file name
+ # arguments, but allows long options with no arguments to work.
+ if [ -f "$arg" -o -d "$arg" ]; then
+ OPTS+=("$arg")
+ else
+ [ "${OPT_PASSTHROUGH[-1]}" = "--stripe-count" ] &&
+ STRIPE_COUNT="$arg"
+ [ "${OPT_PASSTHROUGH[-1]}" = "--stripe-size" ] &&
+ STRIPE_SIZE="$arg"
+ [ "${OPT_PASSTHROUGH[-1]}" = "--pool" ] &&
+ POOL="$arg"
+ OPT_PASSTHROUGH+=("$arg")
+ fi
+ elif $SHORT_OPT; then
+ [ "${OPTS[-1]}" = "-c" ] &&
+ STRIPE_COUNT="$arg"
+ [ "${OPTS[-1]}" = "-S" ] &&
+ STRIPE_SIZE="$arg"
+ [ "${OPTS[-1]}" = "-p" ] &&
+ POOL="$arg"
+ SHORT_OPT=false
+ OPTS+=("$arg")
+ else
+ OPTS+=("$arg")
+ fi
+done