blob: b9e862d3d4ab9a31bcf1c4deb24b190f82e6a304 (
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/sh
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
grep -q "." <<< "$line" || continue
name=$(echo $line | awk '{ print $1 }')
code=$(echo $line | awk '{ print $2 }')
append_header $name $code
append_sh $name $code
done < "$2"
|