This commit is contained in:
Jack L. Frost 2015-02-20 11:23:26 +03:00
parent 9695ac5418
commit b0d56bc0ea

22
sup
View File

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