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