Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts/library
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-07 11:23:55 -0500
committerDan McGee <dan@archlinux.org>2012-04-07 11:23:55 -0500
commit4ca6590af58177964910588a6d0406f0d009bd0e (patch)
tree3ff2d0d07aa5bd38f13e9456c5f831bdef06b8e2 /scripts/library
parent3f1ea8b62f46a915c94a5b46e21ad39ea2628f65 (diff)
parentb752561a52a88f8e9cc3bcc9c2079eb685245110 (diff)
Merge branch 'maint'
Conflicts: lib/libalpm/signing.c lib/libalpm/sync.c
Diffstat (limited to 'scripts/library')
-rw-r--r--scripts/library/parse_options.sh30
1 files changed, 20 insertions, 10 deletions
diff --git a/scripts/library/parse_options.sh b/scripts/library/parse_options.sh
index 39038de6..039eef92 100644
--- a/scripts/library/parse_options.sh
+++ b/scripts/library/parse_options.sh
@@ -23,15 +23,17 @@ parse_options() {
[[ ${match} = ${1:2}:: && -n $2 && ${2:0:1} != "-" ]] && needsargument=1
if (( ! needsargument )); then
- OPTRET+=("$1")
+ printf ' %s' "$1"
else
if [[ -n $2 ]]; then
- OPTRET+=("$1" "$2")
+ printf ' %s ' "$1"
shift
+ printf "'%q" "$1"
while [[ -n $2 && ${2:0:1} != "-" ]]; do
shift
- OPTRET+=("$1")
+ printf " %q" "$1"
done
+ printf "'"
else
printf "@SCRIPTNAME@: $(gettext "option %s requires an argument\n")" "'$1'" >&2
ret=1
@@ -55,22 +57,26 @@ parse_options() {
( -n ${1:$i+1} || ( -n $2 && ${2:0:1} != "-" ) ) ]] && needsargument=1
if (( ! needsargument )); then
- OPTRET+=("-${1:i:1}")
+ printf ' -%s' "${1:i:1}"
else
if [[ -n ${1:$i+1} ]]; then
- OPTRET+=("-${1:i:1}" "${1:i+1}")
+ printf ' -%s ' "${1:i:1}"
+ printf "'%q" "${1:$i+1}"
while [[ -n $2 && ${2:0:1} != "-" ]]; do
shift
- OPTRET+=("$1")
+ printf " %q" "$1"
done
+ printf "'"
else
if [[ -n $2 ]]; then
- OPTRET+=("-${1:i:1}" "$2")
+ printf ' -%s ' "${1:i:1}"
shift
+ printf "'%q" "$1"
while [[ -n $2 && ${2:0:1} != "-" ]]; do
shift
- OPTRET+=("$1")
+ printf " %q" "$1"
done
+ printf "'"
else
printf "@SCRIPTNAME@: $(gettext "option %s requires an argument\n")" "'-${1:i:1}'" >&2
@@ -85,11 +91,15 @@ parse_options() {
fi
done
else
- unused_options+=("$1")
+ unused_options="${unused_options} '$1'"
fi
shift
done
- OPTRET+=('--' "${unused_options[@]}")
+ printf " --"
+ [[ $unused_options ]] && printf ' %s' "${unused_options[@]}"
+ [[ $1 ]] && printf " '%s'" "$@"
+ printf "\n"
+
return $ret
}