1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 07:48:50 -05:00

parseopts: remove superfluous continue/shift statements

Fun fact about bash: the below is valid and will only ever print 'a'!

  fn() {
    continue 2
  }

  for x in {1..5}; do
    for y in {a..e}; do
      echo "$y"
      fn
    done
  done

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Dave Reisner 2013-01-01 22:43:20 -05:00 committed by Allan McRae
parent 1dd3405813
commit 60d2588192

View File

@ -92,26 +92,22 @@ parseopts() {
# --longopt # --longopt
else else
OPTRET+=("--$opt") OPTRET+=("--$opt")
shift
continue 2
fi fi
;; ;;
1) 1)
# --longopt=optarg # --longopt=optarg
if [[ $optarg ]]; then if [[ $optarg ]]; then
OPTRET+=("--$opt" "$optarg") OPTRET+=("--$opt" "$optarg")
shift
# --longopt optarg # --longopt optarg
elif [[ $2 ]]; then elif [[ $2 ]]; then
OPTRET+=("--$opt" "$2" ) OPTRET+=("--$opt" "$2" )
shift 2 shift
# parse failure # parse failure
else else
printf "@SCRIPTNAME@: $(gettext "option '%s' requires an argument")\n" "--$opt" >&2 printf "@SCRIPTNAME@: $(gettext "option '%s' requires an argument")\n" "--$opt" >&2
OPTRET=(--) OPTRET=(--)
return 1 return 1
fi fi
continue 2
;; ;;
254) 254)
# ambiguous option -- error was reported for us by longoptmatch() # ambiguous option -- error was reported for us by longoptmatch()