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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
#!/bin/sh
# $XTermId: run-tic.sh,v 1.15 2022/02/13 14:30:33 tom Exp $
# -----------------------------------------------------------------------------
# this file is part of xterm
#
# Copyright 2006-2021,2022 by Thomas E. Dickey
#
# All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
# -----------------------------------------------------------------------------
#
# Run tic, either using ncurses' extension feature or filtering out harmless
# messages for the extensions which are otherwise ignored by other versions of
# tic.
USE_NCURSES=20190609
failed() {
echo "? $*" >&2
exit 1
}
need_ncurses() {
failed "This terminal description relies on ncurses 6.1 $USE_NCURSES"
}
use_ncurses6() {
VER=`infocmp6 -V 2>/dev/null`
test -n "$VER" && INFOCMP_PROG=infocmp6
VER=`tic6 -V 2>/dev/null`
test -n "$VER" && TIC_PROG=tic6
test -z "$VER" && need_ncurses
}
MYTEMP=`mktemp -d 2>/dev/null`
if test -z "$MYTEMP"
then
MYTEMP=${TMPDIR:-/tmp}/run-tic$$
fi
mkdir -p "$MYTEMP" || failed "cannot mkdir $MYTEMP"
trap "rm -rf $MYTEMP; exit 1" 1 2 3 15
trap "rm -rf $MYTEMP" 0
STDERR=$MYTEMP/run-tic$$.log
VER=`tic -V 2>/dev/null`
OPT=
TIC_PROG=tic
INFOCMP_PROG=infocmp
unset TERM
unset TERMINFO_DIRS
PASS1="$*"
PASS2="$*"
case "x$VER" in
*ncurses*)
OPT="-x"
# Prefer ncurses 6.1 over 6.0 over any 5, if we can get it, to support
# large numbers (used in xterm-direct) and large entries (an issue with
# xterm-nrc).
case "$VER" in
*\ [7-9].*|*\ 6.[1-9].20[12][0-9]*)
check=`echo "$VER" | sed -e 's/^.*\.//' -e 's/[^0-9].*$//'`
[ "$check" -ge "20210626" ] && \
[ "$check" -lt "20210828" ] && use_ncurses6
[ "$check" -lt "$USE_NCURSES" ] && use_ncurses6
;;
*)
# On systems with only ncurses 5, check for development version
# of ncurses.
use_ncurses6
;;
esac
echo "** using tic from $VER"
# If this is 6.1.20180127 or later and using ABI 6, then it supports
# entries larger than 4096 bytes (up to 32768).
case "$VER" in
*\ [7-9].*|*\ 6.[1-9].20[12][0-9]*)
expect=" cols#100000,"
cat >"$MYTEMP"/fake.ti <<EOF
fake|test 32-bit numbers,
$expect
EOF
TERMINFO="$MYTEMP" $TIC_PROG $OPT "$MYTEMP"/fake.ti 2>/dev/null
check=`TERMINFO="$MYTEMP" TERM=fake $INFOCMP_PROG -1 fake 2>/dev/null |grep "$expect"`
test "x$check" = "x$expect" || BIG=no
;;
*)
BIG=no
;;
esac
if test "$BIG" = no
then
# Trim out the SGR 1006 feature, to keep "xterm-nrc" smaller
# than 4096 bytes.
echo "...this version does not support large terminal descriptions"
PASS2=$MYTEMP/input
sed -e 's/use=xterm+sm+1006,//' -e '/^[ ][ ]*$/d' "$PASS1" >"$PASS2"
set "$PASS2"
fi
;;
esac
echo "** $TIC_PROG $OPT $PASS1"
$TIC_PROG $OPT "$PASS2" 2>"$STDERR"
RET=$?
sed -e "s%$PASS2%$PASS1%" "$STDERR" | \
${FGREP-fgrep} -v 'Unknown Capability' | \
${FGREP-fgrep} -v 'Capability is not recognized:' | \
${FGREP-fgrep} -v 'tic: Warning near line ' >&2
rm -f "$STDERR"
exit $RET
|