Merge pull request #457 from vivien/text-variable
[tig.git] / tools / make-builtin-config.sh
blobb58a1457e15c7e9e3049be07ee18c0ed53eb3873
1 #!/bin/sh
3 # Generate code for including a copy of the default tigrc inside the
4 # binary.
6 # Usage: $0 /path/to/tigrc
8 # Copyright (c) 2014 Jonas Fonseca <jonas.fonseca@gmail.com>
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation; either version 2 of
13 # the License, or (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 TIGRC="${1:-tigrc}"
22 read_tigrc() {
23 if test -z "$NO_BUILTIN_TIGRC"; then
24 sed 's/\s*#.*//' "$TIGRC" | sed 's,\\,\\\\\\\\,g' | sed 's,",\\\\",g' | sed 's/ \+/ /g'
25 else
26 echo '#'
30 echo "/* Generated by $0 on $(date) */"
31 echo "const char *builtin_config ="
33 read_tigrc | while read line; do
34 case "$line" in
35 "") : ignore ;;
36 *) printf ' "%s\\n"\n' "$line"
37 esac
38 done
40 echo ";"