Browse code

Update check-config.sh to use "case" instead of an associative array

This fixes Bash 3.x compatibility (where associative arrays are not available).

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>

Tianon Gravi authored on 2016/01/13 13:57:56
Showing 1 changed files
... ...
@@ -38,28 +38,31 @@ is_set_as_module() {
38 38
 	zgrep "CONFIG_$1=m" "$CONFIG" > /dev/null
39 39
 }
40 40
 
41
-# see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
42
-declare -A colors=(
43
-	[black]=30
44
-	[red]=31
45
-	[green]=32
46
-	[yellow]=33
47
-	[blue]=34
48
-	[magenta]=35
49
-	[cyan]=36
50
-	[white]=37
51
-)
52 41
 color() {
53
-	color=()
42
+	local codes=()
54 43
 	if [ "$1" = 'bold' ]; then
55
-		color+=( '1' )
44
+		codes=( "${codes[@]}" '1' )
56 45
 		shift
57 46
 	fi
58
-	if [ $# -gt 0 ] && [ "${colors[$1]}" ]; then
59
-		color+=( "${colors[$1]}" )
47
+	if [ "$#" -gt 0 ]; then
48
+		local code=
49
+		case "$1" in
50
+			# see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
51
+			black) code=30 ;;
52
+			red) code=31 ;;
53
+			green) code=32 ;;
54
+			yellow) code=33 ;;
55
+			blue) code=34 ;;
56
+			magenta) code=35 ;;
57
+			cyan) code=36 ;;
58
+			white) code=37 ;;
59
+		esac
60
+		if [ "$code" ]; then
61
+			codes=( "${codes[@]}" "$code" )
62
+		fi
60 63
 	fi
61 64
 	local IFS=';'
62
-	echo -en '\033['"${color[*]}"m
65
+	echo -en '\033['"${codes[*]}"'m'
63 66
 }
64 67
 wrap_color() {
65 68
 	text="$1"