summaryrefslogtreecommitdiffstats
path: root/scripts/library
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-02-21 00:00:26 +0100
committerDan McGee <dan@archlinux.org>2012-02-21 00:00:26 +0100
commit3849c3aec130601572b9e06b42bb6af5938936de (patch)
treef298f227f4ff591390e55b4f02812f12312dd5c7 /scripts/library
parent326c6a8eed60bfd6aa0d653dad722d8637022d68 (diff)
parent78adb71f20ee335dff49e34d33f04817a40002b6 (diff)
downloadpacman-3849c3aec130601572b9e06b42bb6af5938936de.tar.gz
pacman-3849c3aec130601572b9e06b42bb6af5938936de.tar.xz
Merge branch 'maint'
Conflicts: contrib/pacsysclean.in src/pacman/conf.h
Diffstat (limited to 'scripts/library')
-rw-r--r--scripts/library/parse_options.sh32
1 files changed, 11 insertions, 21 deletions
diff --git a/scripts/library/parse_options.sh b/scripts/library/parse_options.sh
index 48fd42cd..39038de6 100644
--- a/scripts/library/parse_options.sh
+++ b/scripts/library/parse_options.sh
@@ -23,17 +23,15 @@ parse_options() {
[[ ${match} = ${1:2}:: && -n $2 && ${2:0:1} != "-" ]] && needsargument=1
if (( ! needsargument )); then
- printf ' %s' "$1"
+ OPTRET+=("$1")
else
if [[ -n $2 ]]; then
- printf ' %s ' "$1"
+ OPTRET+=("$1" "$2")
shift
- printf "'%q" "$1"
while [[ -n $2 && ${2:0:1} != "-" ]]; do
shift
- printf " %q" "$1"
+ OPTRET+=("$1")
done
- printf "'"
else
printf "@SCRIPTNAME@: $(gettext "option %s requires an argument\n")" "'$1'" >&2
ret=1
@@ -57,26 +55,22 @@ parse_options() {
( -n ${1:$i+1} || ( -n $2 && ${2:0:1} != "-" ) ) ]] && needsargument=1
if (( ! needsargument )); then
- printf ' -%s' "${1:i:1}"
+ OPTRET+=("-${1:i:1}")
else
if [[ -n ${1:$i+1} ]]; then
- printf ' -%s ' "${1:i:1}"
- printf "'%q" "${1:$i+1}"
+ OPTRET+=("-${1:i:1}" "${1:i+1}")
while [[ -n $2 && ${2:0:1} != "-" ]]; do
shift
- printf " %q" "$1"
+ OPTRET+=("$1")
done
- printf "'"
else
if [[ -n $2 ]]; then
- printf ' -%s ' "${1:i:1}"
+ OPTRET+=("-${1:i:1}" "$2")
shift
- printf "'%q" "$1"
while [[ -n $2 && ${2:0:1} != "-" ]]; do
shift
- printf " %q" "$1"
+ OPTRET+=("$1")
done
- printf "'"
else
printf "@SCRIPTNAME@: $(gettext "option %s requires an argument\n")" "'-${1:i:1}'" >&2
@@ -91,15 +85,11 @@ parse_options() {
fi
done
else
- unused_options="${unused_options} '$1'"
+ unused_options+=("$1")
fi
shift
done
- printf " --"
- [[ $unused_options ]] && printf ' %s' "${unused_options[@]}"
- [[ $1 ]] && printf " '%s'" "$@"
- printf "\n"
-
+ OPTRET+=('--' "${unused_options[@]}")
return $ret
-} \ No newline at end of file
+}