blob: 2f0bfcf8bdc82ea6299270de55ba85b7717df692 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/bash
PREFIX=$1
headerfile=${PREFIX}"/include/colors.h"
shlib=${PREFIX}"/lib/colors.sh"
cat > $shlib << "EOF"
#
# colors.h
#
# list of ansi color codes
# provided by xiutils
#
EOF
cat > $headerfile << "EOF"
/*
* colors.h
*
* list of ansi color codes
* provided by xiutils
*
*/
EOF
append_header() {
echo "#define $1 $2" >> $headerfile
}
append_sh() {
printf "export %s=$'%s'\n" $1 $(echo $2 | sed -rn "s/\"(.*)\"/\1/p") >> $shlib
}
while IFS= read -r line; do
echo "$line" | grep -q "." || continue
name=$(echo $line | awk '{ print $1 }')
code=$(echo $line | awk '{ print $2 }')
append_header $name $code
append_sh $name $code
done < "$2"
|