Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts/libmakepkg/util
diff options
context:
space:
mode:
authorEthan Sommer <e5ten.arch@gmail.com>2019-11-04 23:36:02 -0500
committerAllan McRae <allan@archlinux.org>2019-11-05 14:47:15 +1000
commit1bfae7d14a7bdad777e82912c5c6883deb11aee5 (patch)
treea41965597b631f363d36c943cceb4694f151469d /scripts/libmakepkg/util
parent091b244d0ffa281ba9968606184d709e59c2a2d5 (diff)
libmakepkg: fix empty arguments in parseopts
Previously parseopts checked if there was an argument by checking that the string was non-empty, resulting in empty arguments being incorrectly considered non-existent. This change makes parseopts check if arguments exist at all, rather than checking that they are non-empty Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/libmakepkg/util')
-rw-r--r--scripts/libmakepkg/util/parseopts.sh.in8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/libmakepkg/util/parseopts.sh.in b/scripts/libmakepkg/util/parseopts.sh.in
index 38ff7f62..698f2acb 100644
--- a/scripts/libmakepkg/util/parseopts.sh.in
+++ b/scripts/libmakepkg/util/parseopts.sh.in
@@ -103,7 +103,7 @@ parseopts() {
OPTRET+=("-$opt" "${1:i+1}")
break
# if we're at the end, grab the the next positional, if it exists
- elif (( i == ${#1} - 1 )) && [[ $2 ]]; then
+ elif (( i == ${#1} - 1 && $# > 1 )); then
OPTRET+=("-$opt" "$2")
shift
break
@@ -144,7 +144,7 @@ parseopts() {
case $? in
0)
# parse failure
- if [[ $optarg ]]; then
+ if [[ $1 = *=* ]]; then
printf "${0##*/}: $(gettext "option '%s' does not allow an argument")\n" "--$opt" >&2
OPTRET=(--)
return 1
@@ -155,10 +155,10 @@ parseopts() {
;;
1)
# --longopt=optarg
- if [[ $optarg ]]; then
+ if [[ $1 = *=* ]]; then
OPTRET+=("--$opt" "$optarg")
# --longopt optarg
- elif [[ $2 ]]; then
+ elif (( $# > 1 )); then
OPTRET+=("--$opt" "$2" )
shift
# parse failure