terminology/data/colorschemes/builder.sh

32 lines
642 B
Bash
Raw Normal View History

2020-09-13 14:39:34 -07:00
#!/bin/sh
set -e
set -u
COMPRESS=1
EET=$1
shift
OUTPUT=$1
shift
2020-10-07 14:48:04 -07:00
INI2DESC=$(dirname "$0")/ini2desc.py
2020-09-13 14:39:34 -07:00
# work on a temporary file till every insertion worked
TMP_EET=$(mktemp "$OUTPUT-XXXXXX")
# trap to avoid creating orphan files
trap 'rm -f "$TMPFILE"' INT TERM HUP EXIT
2020-10-07 14:48:04 -07:00
for INI in "$@"
2020-09-13 14:39:34 -07:00
do
# use the name, without extension as key in eet
2020-10-07 14:48:04 -07:00
KEY=$(basename "$INI" ".ini")
DESC="${KEY}.desc"
2020-10-07 14:48:04 -07:00
$INI2DESC "$INI" "$DESC"
2020-09-13 14:39:34 -07:00
$EET -e "$TMP_EET" "$KEY" "$DESC" "$COMPRESS"
done
# atomic rename to the expected output file
mv "$TMP_EET" "$OUTPUT"
# file successfully renamed, so need to trap to rename temp file
trap - INT TERM HUP EXIT