File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 99shopt -s extglob
1010
1111normalize_bool () {
12- # Returns either "True" or "False"
12+ # Returns either "True" or "False", or possibly "None" if a third argument is given
1313 local varname=" $1 "
1414 local raw_value=" ${! varname:- } "
1515 local value=" ${raw_value,,} " # Convert to lowercase
1616 local default=" ${2:- False} "
17+ local allow_none=" ${3:- } "
1718
1819 case " $value " in
1920 true | enable | enabled | yes | y | 1 | on)
@@ -26,8 +27,12 @@ normalize_bool() {
2627 echo " $default "
2728 ;;
2829 * )
29- echo " WARNING: Invalid boolean ('$raw_value ') for '$varname '; defaulting to $default " >&2
30- echo " $default "
30+ if [ -n " $allow_none " ] && [ " $value " = " none" ]; then
31+ echo " None"
32+ else
33+ echo " WARNING: Invalid boolean ('$raw_value ') for '$varname '; defaulting to $default " >&2
34+ echo " $default "
35+ fi
3136 ;;
3237 esac
3338}
@@ -137,7 +142,15 @@ setConfigurationValue() {
137142 literal)
138143 VALUE=" $1 "
139144 ;;
140- bool | integer | array)
145+ bool)
146+ # Note that if any settings were explicitly set as type
147+ # "bool" (which none are at current), this would provide a
148+ # slightly confusing error message with "PROVIDED_SETTING"
149+ # in it, rather than the actual setting name.
150+ local PROVIDED_SETTING=" $2 "
151+ VALUE=" $KEY = $( normalize_bool PROVIDED_SETTING False allow_none) "
152+ ;;
153+ integer | array)
141154 VALUE=" $KEY = $2 "
142155 ;;
143156 string)
You can’t perform that action at this time.
0 commit comments