diff options
author | Marcin Chrzanowski <m@m-chrzan.xyz> | 2021-12-30 15:04:09 +0100 |
---|---|---|
committer | Marcin Chrzanowski <m@m-chrzan.xyz> | 2021-12-30 15:04:09 +0100 |
commit | 3099d3f9f367196c05820951f25a75116f0bbaaf (patch) | |
tree | dd8755c43aaf41b206bbd7905ff6e1a8fa276b84 | |
parent | a664862cda9ab53dad57b23ebf4c1374495d7043 (diff) |
Add getopts
-rw-r--r-- | bash.md | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -77,3 +77,14 @@ All keys: ${!array[*]} ${!array[@]} + +## Getopts example + + while getopts 'a:b:c' flag; do + case "${flag}" in + a) do_something $OPTARG ;; + b) b_option=$OPTARG ;; + c) c_flag=1 ;; + *) error "Unexpected option ${flag}" ;; + esac + done |