Browse Source

argv

master
Jack L. Frost 7 years ago
parent
commit
b0d56bc0ea
  1. 22
      sup

22
sup

@ -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[@]}"

Loading…
Cancel
Save