getopt implementation
This commit is contained in:
parent
28fd9cddde
commit
4f06fec784
28
sup
28
sup
|
@ -90,7 +90,33 @@ sup.mktemp() {
|
|||
echo "${tmp_dir}/${tmp_file_name}"
|
||||
}
|
||||
|
||||
sup.getopt() {
|
||||
local keys
|
||||
|
||||
for i in "$@"; do
|
||||
case "$i" in
|
||||
--*) echo "$i";;
|
||||
|
||||
-*)
|
||||
keys=( `echo "${i##*-}" | fold -w1` )
|
||||
|
||||
[[ "${#keys[@]}" -gt 1 ]] && {
|
||||
for k in ${keys[@]}; do
|
||||
echo "-${k}"
|
||||
done
|
||||
} || {
|
||||
echo "$i"
|
||||
}
|
||||
;;
|
||||
|
||||
*) echo "$i";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
local args file target flag_private flag_rm flag_scrot flag_scrot_fullscreen cfg_scrot_delay
|
||||
|
||||
while [[ "$1" ]]; do
|
||||
case "$1" in
|
||||
-p|--private) flag_private='true';;
|
||||
|
@ -129,4 +155,4 @@ main() {
|
|||
sup.upload
|
||||
}
|
||||
|
||||
main "$@"
|
||||
main $(sup.getopt "$@")
|
||||
|
|
Loading…
Reference in New Issue
Block a user