mirror of
https://github.com/octoleo/hosts.git
synced 2025-02-11 23:08:30 +00:00
Clean up program option parsing section.
This commit is contained in:
parent
d242aed463
commit
73ecc3119e
25
hosts
25
hosts
@ -1668,26 +1668,8 @@ unblock() {
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Options
|
# Options
|
||||||
#
|
|
||||||
# NOTE: The `getops` builtin command only parses short options and BSD `getopt`
|
|
||||||
# does not support long arguments (GNU `getopt` does), so the most portable
|
|
||||||
# and clear way to parse options is often to just use a `while` loop.
|
|
||||||
#
|
|
||||||
# For a pure bash `getopt` function, try pure-getopt:
|
|
||||||
# https://github.com/agriffis/pure-getopt
|
|
||||||
#
|
|
||||||
# More info:
|
|
||||||
# http://wiki.bash-hackers.org/scripting/posparams
|
|
||||||
# http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
|
|
||||||
# http://stackoverflow.com/a/14203146
|
|
||||||
# http://stackoverflow.com/a/7948533
|
|
||||||
# https://stackoverflow.com/a/12026302
|
|
||||||
# https://stackoverflow.com/a/402410
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Get raw options for any commands that expect them.
|
|
||||||
_RAW_OPTIONS="${*:-}"
|
|
||||||
|
|
||||||
# Parse Options ###############################################################
|
# Parse Options ###############################################################
|
||||||
|
|
||||||
_CMD=""
|
_CMD=""
|
||||||
@ -1749,13 +1731,10 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
_debug printf \
|
_debug printf \
|
||||||
"\${_CMD}: %s\\n" \
|
"\${_CMD}: %s\\n" \
|
||||||
"${_CMD}"
|
"${_CMD}"
|
||||||
_debug printf \
|
_debug printf \
|
||||||
"\${_RAW_OPTIONS} (one per line):\\n%s\\n" \
|
|
||||||
"${_RAW_OPTIONS}"
|
|
||||||
_debug printf \
|
|
||||||
"\${_COMMAND_PARAMETERS[*]:-}: %s\\n" \
|
"\${_COMMAND_PARAMETERS[*]:-}: %s\\n" \
|
||||||
"${_COMMAND_PARAMETERS[*]:-}"
|
"${_COMMAND_PARAMETERS[*]:-}"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user