| #!/bin/bash |
| ## ----------------------------------------------------------------------- |
| ## ----------------------------------------------------------------------- |
| |
| ## ----------------------------------------------------------------------- |
| ## Intent: Detect if the --{labels,required}-is-empty switch is valid |
| ## ----------------------------------------------------------------------- |
| function is_switch_valid__is_empty() |
| { |
| local raw="$1"; shift # --{foo}-is-empty |
| |
| declare -a valid=() |
| valid+=('label') |
| valid+=('resolved') |
| |
| # --required-is-empty => required |
| local val="$raw" |
| val="${val:2}" # remove prefix -- |
| val="${val%-is-empty}" # remove suffix token-name |
| |
| if [[ " ${valid[@]} " =~ " ${val} " ]]; then |
| is_empty+=("$val") |
| else |
| error "Detected invalid --empty switch [$arg]" |
| fi |
| |
| return |
| } |
| |
| : # ($?=0) for source $include |
| |
| # [EOF] |