This commit is contained in:
Jack L. Frost 2015-02-20 11:23:26 +03:00
parent 9695ac5418
commit b0d56bc0ea
1 changed files with 12 additions and 10 deletions

22
sup
View File

@ -92,19 +92,22 @@ sup.mktemp() {
echo "${tmp_dir}/${tmp_file_name}"
}
sup.getopt() {
sup.set_argv() {
declare arg opt c
declare -g argv
while (( $# )); do
unset -v arg opt c keys
unset -v arg opt c
case "$1" in
(--) printf '%s\n' '--'; break;;
(--) argv+=( "$1" ); break;;
(--*)
IFS='=' read arg opt <<< "$1"
printf '%s\n' "$arg"
argv+=( "$arg" )
[[ "$opt" ]] && {
printf '%s\n' "$opt"
argv+=( "$opt" )
}
;;
@ -113,14 +116,12 @@ sup.getopt() {
do
case "$c" in
-|'') :;;
*) keys+=( "-$c" );;
*) argv+=( "-$c" );;
esac
done <<< "$1"
printf '%s\n' "${keys[@]}"
;;
(*) printf '%s\n' "$1";;
(*) argv+=( "$1" );;
esac
shift
done
@ -174,4 +175,5 @@ main() {
sup.upload
}
main $(sup.getopt "$@")
sup.set_argv "$@"
main "${argv[@]}"