Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | ## ----------------------------------------------------------------------- |
| 3 | ## ----------------------------------------------------------------------- |
| 4 | |
| 5 | ## ----------------------------------------------------------------------- |
| 6 | ## Intent: Detect if the --{labels,required}-is-empty switch is valid |
| 7 | ## ----------------------------------------------------------------------- |
| 8 | function is_switch_valid__is_empty() |
| 9 | { |
| 10 | local raw="$1"; shift # --{foo}-is-empty |
| 11 | |
| 12 | declare -a valid=() |
| 13 | valid+=('label') |
| 14 | valid+=('resolved') |
| 15 | |
| 16 | # --required-is-empty => required |
| 17 | local val="$raw" |
| 18 | val="${val:2}" # remove prefix -- |
| 19 | val="${val%-is-empty}" # remove suffix token-name |
| 20 | |
| 21 | if [[ " ${valid[@]} " =~ " ${val} " ]]; then |
| 22 | is_empty+=("$val") |
| 23 | else |
| 24 | error "Detected invalid --is-empty switch [$arg]" |
| 25 | fi |
| 26 | |
| 27 | return |
| 28 | } |
| 29 | |
| 30 | : # ($?=0) for source $include |
| 31 | |
| 32 | # [EOF] |