2006-12-19 00:17:11 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
tmp1=$(mktemp ${TMPDIR:-/tmp}/${0##*/}.XXXXXX) || exit 1
|
|
|
|
|
trap "rm -f $tmp1; exit" EXIT SIGPIPE SIGTERM SIGINT
|
|
|
|
|
tmp2=$(mktemp ${TMPDIR:-/tmp}/${0##*/}.XXXXXX) || exit 1
|
|
|
|
|
trap "rm -f $tmp1 $tmp2; exit" EXIT SIGPIPE SIGTERM SIGINT
|
|
|
|
|
|
|
|
|
|
: ${TERMCAP:=/etc/termcap}
|
|
|
|
|
: ${TERMINFO:=/usr/share/terminfo}
|
2013-03-26 14:01:42 +01:00
|
|
|
|
: ${BUILD_TIC:=/usr/bin/tic}
|
|
|
|
|
: ${BUILD_INFOCMP:=/usr/bin/infocmp}
|
2006-12-19 00:17:11 +01:00
|
|
|
|
acsc=
|
|
|
|
|
sgr=
|
|
|
|
|
mpch=
|
|
|
|
|
new=
|
|
|
|
|
ed=
|
|
|
|
|
declare -i line=0
|
|
|
|
|
|
|
|
|
|
if test -r run_cmd.sh ; then
|
2019-12-16 11:34:37 +01:00
|
|
|
|
function tc { sh run_cmd.sh $BUILD_TIC -0 -U -C -r ${1+"$@"}; }
|
2013-03-26 14:01:42 +01:00
|
|
|
|
function ic { sh run_cmd.sh $BUILD_INFOCMP -A $TERMINFO ${1+"$@"}; }
|
2006-12-19 00:17:11 +01:00
|
|
|
|
else
|
2019-12-16 11:34:37 +01:00
|
|
|
|
function tc { $BUILD_TIC -0 -U -C -r ${1+"$@"}; }
|
2013-03-26 14:01:42 +01:00
|
|
|
|
function ic { $BUILD_INFOCMP -A $TERMINFO ${1+"$@"}; }
|
2006-12-19 00:17:11 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cp $TERMCAP ${TERMCAP##*/}.new
|
|
|
|
|
set -o noglob
|
|
|
|
|
OIFS="$IFS"
|
|
|
|
|
IFS='
|
|
|
|
|
'
|
|
|
|
|
for l in $(grep '^linux' $TERMCAP); do
|
|
|
|
|
[[ $l =~ linux-vt* ]] && continue
|
|
|
|
|
[[ $l =~ linux-basic* ]] && continue
|
|
|
|
|
ic -1 -T ${l%%|*} > $tmp2
|
|
|
|
|
|
|
|
|
|
grep -E '^linux|acsc=' < $tmp2 > $tmp1
|
|
|
|
|
acsc="$(tc $tmp1 | grep -v '^linux')"
|
|
|
|
|
|
|
|
|
|
grep -E '^linux|sgr=' < $tmp2 > $tmp1
|
|
|
|
|
sgr="$(tc $tmp1 | grep -v '^linux')"
|
|
|
|
|
|
|
|
|
|
grep -E '^linux|(smpch|rmpch)=' < $tmp2 > $tmp1
|
|
|
|
|
mpch="$(tc $tmp1 | grep -v '^linux')"
|
|
|
|
|
|
|
|
|
|
entry="$(tc $tmp2 | grep -v '^#')"
|
|
|
|
|
|
2019-12-16 11:34:37 +01:00
|
|
|
|
new=$(echo "$entry" | sed -e '\:a[el]=.*a\
|
|
|
|
|
:ac=' | sed -e "s\t:ac=${acsc//\\/\\\\}\\\\")
|
2006-12-19 00:17:11 +01:00
|
|
|
|
new=$(echo "$new" | sed -e '/:a[el]=.*/i\
|
2019-12-16 11:34:37 +01:00
|
|
|
|
:S2=' | sed -e "s\t:S2=${mpch//\\/\\\\}\\\\")
|
|
|
|
|
new=$(echo "$new" | sed -e '\:s.=.*i\
|
|
|
|
|
:\.\.sa=' | sed -e "s\t:\.\.sa=${sgr//\\/\\\\}\\\\")
|
2006-12-19 00:17:11 +01:00
|
|
|
|
|
|
|
|
|
if test "${#new}" -gt 1024 ; then
|
2019-12-16 11:34:37 +01:00
|
|
|
|
new=$(echo "$entry" | sed -e '\\t:a[el]=.*a\
|
|
|
|
|
:ac=' | sed -e "s\t:ac=${acsc//\\/\\\\}\\\\")
|
2006-12-19 00:17:11 +01:00
|
|
|
|
new=$(echo "$new" | sed -e '/\t:a[el]=.*/i\
|
2019-12-16 11:34:37 +01:00
|
|
|
|
:S2=' | sed -e "s\t:S2=${mpch//\\/\\\\}\\\\")
|
2006-12-19 00:17:11 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if test "${#new}" -gt 1024 ; then
|
2019-12-16 11:34:37 +01:00
|
|
|
|
new=$(echo "$entry" | sed -e '\\t:a[el]=.*i\
|
|
|
|
|
:S2=' | sed -e "s\t:S2=${mpch//\\/\\\\}\\\\")
|
2006-12-19 00:17:11 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if test "${#new}" -gt 1024 ; then
|
|
|
|
|
new="$entry"
|
|
|
|
|
fi
|
|
|
|
|
|
2019-12-16 11:34:37 +01:00
|
|
|
|
line=$(grep -n "${l//\\/\\\\}" ${TERMCAP##*/}.new| sed 's:.*')
|
2006-12-19 00:17:11 +01:00
|
|
|
|
: $((line--))
|
|
|
|
|
echo "$entry" > $tmp1
|
|
|
|
|
echo "$new" > $tmp2
|
|
|
|
|
|
2019-12-16 11:34:37 +01:00
|
|
|
|
ed=$(diff -e $tmp1 $tmp2| sed "s^\([0-9]\+a\)$line\n+\1")
|
2006-12-19 00:17:11 +01:00
|
|
|
|
|
|
|
|
|
ed ${TERMCAP##*/}.new &> /dev/null <<-EOF
|
|
|
|
|
${ed}
|
|
|
|
|
w
|
|
|
|
|
q
|
|
|
|
|
EOF
|
|
|
|
|
done
|
|
|
|
|
IFS="$OIFS"
|
|
|
|
|
unset entry acsc sgr mpch
|