From 5fcd199a90e9e3e68e50b7644a091ad8fa20027a Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 18 Jun 2012 16:25:00 -0400 Subject: [PATCH] new example for getopts. --- examples/bashisms/example_getops_parsing.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/bashisms/example_getops_parsing.txt diff --git a/examples/bashisms/example_getops_parsing.txt b/examples/bashisms/example_getops_parsing.txt new file mode 100644 index 00000000..1f26b80a --- /dev/null +++ b/examples/bashisms/example_getops_parsing.txt @@ -0,0 +1,16 @@ + +# shell option parsing -- old school version only handles single dash options. + +while getopts "fr:q:a:h" opt; do + case "${opt}" in + f) force_query=1; ;; + r) row_num="${OPTARG}"; ;; + q) queue_name="${OPTARG}"; ;; + a) alias_name="${OPTARG}"; ;; + h) usage 1>&2; exit ${EX_OK}; ;; + ?) usage 1>&2; exit ${EX_USAGE}; ;; + esac +done + +shift $(($OPTIND - 1)) + -- 2.34.1