blob: 0858b36757425d100dfab7fcaa4f32e08fff6509 [file] [log] [blame]
Joey Armstrongf8c78f02024-08-28 17:00:29 -04001#!/bin/bash
2## -----------------------------------------------------------------------
3## -----------------------------------------------------------------------
4
5## -----------------------------------------------------------------------
6## Intent: Parse command line switch, when *-not detected take action
7## - remove substring '-not' modifier from switch name
8## - set values in map %attrs=() to capture detection of NOT
9## - switch value returned modified
10## Return:
11## %attrs ['not']=true
12## -----------------------------------------------------------------------
13function getopts_switch__not()
14{
15 local -n gsn_arg=$1 ; shift
16 declare -g -A attrs
17
18 case "$gsn_arg" in
19
20 # -[-not]
21 '--not')
22 attrs['not']=1
23 gsn_argv=''
24 local -i rc=0
25 ;;
26
27 # --reserved-is[-not]-empty
28 *'-not'*)
29 declare -a args=()
30 attrs['not']=1
31 gsn_arg="${gsn_arg/-not/}"
32 local -i rc=0
33 ;;
34
35 *) local -i rc=1 ;;
36 esac
37
38 [[ $rc -eq 0 ]] && { true; } || { false; }
39 return
40}
41
42# [EOF]