3 local short_options
=$1; shift;
4 local long_options
=$1; shift;
6 local unused_options
=""
10 if [[ ${1:0:2} = '--' ]]; then
11 if [[ -n ${1:2} ]]; then
13 for i
in ${long_options//,/ }; do
14 if [[ ${1:2} = ${i//:} ]]; then
19 if [[ -n $match ]]; then
20 if [[ ${1:2} = $match ]]; then
28 printf "@SCRIPTNAME@: $(gettext "option
%s requires an argument
")" "'$1'" >&2
33 echo "@SCRIPTNAME@: $(gettext "unrecognized option
") '$1'" >&2
40 elif [[ ${1:0:1} = '-' ]]; then
41 for ((i
=1; i
<${#1}; i
++)); do
42 if [[ $short_options =~
${1:i:1} ]]; then
43 if [[ $short_options =~
${1:i:1}: ]]; then
44 if [[ -n ${1:$i+1} ]]; then
45 printf ' -%s' "${1:i:1}"
46 printf " '%s'" "${1:$i+1}"
49 printf ' -%s' "${1:i:1}"
53 printf "@SCRIPTNAME@: $(gettext "option
%s requires an argument
")" "'-${1:i:1}'" >&2
59 printf ' -%s' "${1:i:1}"
62 echo "@SCRIPTNAME@: $(gettext "unrecognized option
") '-${1:i:1}'" >&2
67 unused_options
="${unused_options} '$1'"
73 if [[ -n $unused_options ]]; then
74 for i
in ${unused_options[@]}; do