15307cd1aSmrg#!/bin/sh 204b94745Smrg# $XTermId: run-tic.in,v 1.1 2022/10/02 21:42:36 tom Exp $ 35307cd1aSmrg# ----------------------------------------------------------------------------- 45307cd1aSmrg# this file is part of xterm 55307cd1aSmrg# 65307cd1aSmrg# Copyright 2006-2021,2022 by Thomas E. Dickey 75307cd1aSmrg# 85307cd1aSmrg# All Rights Reserved 95307cd1aSmrg# 105307cd1aSmrg# Permission is hereby granted, free of charge, to any person obtaining a 115307cd1aSmrg# copy of this software and associated documentation files (the 125307cd1aSmrg# "Software"), to deal in the Software without restriction, including 135307cd1aSmrg# without limitation the rights to use, copy, modify, merge, publish, 145307cd1aSmrg# distribute, sublicense, and/or sell copies of the Software, and to 155307cd1aSmrg# permit persons to whom the Software is furnished to do so, subject to 165307cd1aSmrg# the following conditions: 175307cd1aSmrg# 185307cd1aSmrg# The above copyright notice and this permission notice shall be included 195307cd1aSmrg# in all copies or substantial portions of the Software. 205307cd1aSmrg# 215307cd1aSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 225307cd1aSmrg# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 235307cd1aSmrg# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 245307cd1aSmrg# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 255307cd1aSmrg# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 265307cd1aSmrg# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 275307cd1aSmrg# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 285307cd1aSmrg# 295307cd1aSmrg# Except as contained in this notice, the name(s) of the above copyright 305307cd1aSmrg# holders shall not be used in advertising or otherwise to promote the 315307cd1aSmrg# sale, use or other dealings in this Software without prior written 325307cd1aSmrg# authorization. 335307cd1aSmrg# ----------------------------------------------------------------------------- 345307cd1aSmrg# 355307cd1aSmrg# Run tic, either using ncurses' extension feature or filtering out harmless 365307cd1aSmrg# messages for the extensions which are otherwise ignored by other versions of 375307cd1aSmrg# tic. 385307cd1aSmrg 395307cd1aSmrgUSE_NCURSES=20190609 405307cd1aSmrg 415307cd1aSmrgfailed() { 425307cd1aSmrg echo "? $*" >&2 435307cd1aSmrg exit 1 445307cd1aSmrg} 455307cd1aSmrg 465307cd1aSmrgneed_ncurses() { 475307cd1aSmrg failed "This terminal description relies on ncurses 6.1 $USE_NCURSES" 485307cd1aSmrg} 495307cd1aSmrg 505307cd1aSmrguse_ncurses6() { 515307cd1aSmrg VER=`infocmp6 -V 2>/dev/null` 525307cd1aSmrg test -n "$VER" && INFOCMP_PROG=infocmp6 535307cd1aSmrg VER=`tic6 -V 2>/dev/null` 545307cd1aSmrg test -n "$VER" && TIC_PROG=tic6 555307cd1aSmrg test -z "$VER" && need_ncurses 565307cd1aSmrg} 575307cd1aSmrg 585307cd1aSmrgMYTEMP=`mktemp -d 2>/dev/null` 595307cd1aSmrgif test -z "$MYTEMP" 605307cd1aSmrgthen 615307cd1aSmrg MYTEMP=${TMPDIR:-/tmp}/run-tic$$ 625307cd1aSmrgfi 635307cd1aSmrgmkdir -p "$MYTEMP" || failed "cannot mkdir $MYTEMP" 645307cd1aSmrgtrap "rm -rf $MYTEMP; exit 1" 1 2 3 15 655307cd1aSmrgtrap "rm -rf $MYTEMP" 0 665307cd1aSmrg 675307cd1aSmrgSTDERR=$MYTEMP/run-tic$$.log 685307cd1aSmrgVER=`tic -V 2>/dev/null` 695307cd1aSmrgOPT= 705307cd1aSmrg 715307cd1aSmrgTIC_PROG=tic 725307cd1aSmrgINFOCMP_PROG=infocmp 735307cd1aSmrgunset TERM 745307cd1aSmrgunset TERMINFO_DIRS 755307cd1aSmrg 765307cd1aSmrgPASS1="$*" 775307cd1aSmrgPASS2="$*" 785307cd1aSmrg 795307cd1aSmrgcase "x$VER" in 805307cd1aSmrg*ncurses*) 815307cd1aSmrg OPT="-x" 825307cd1aSmrg # Prefer ncurses 6.1 over 6.0 over any 5, if we can get it, to support 835307cd1aSmrg # large numbers (used in xterm-direct) and large entries (an issue with 845307cd1aSmrg # xterm-nrc). 855307cd1aSmrg case "$VER" in 865307cd1aSmrg *\ [7-9].*|*\ 6.[1-9].20[12][0-9]*) 875307cd1aSmrg check=`echo "$VER" | sed -e 's/^.*\.//' -e 's/[^0-9].*$//'` 885307cd1aSmrg [ "$check" -ge "20210626" ] && \ 895307cd1aSmrg [ "$check" -lt "20210828" ] && use_ncurses6 905307cd1aSmrg [ "$check" -lt "$USE_NCURSES" ] && use_ncurses6 915307cd1aSmrg ;; 925307cd1aSmrg *) 935307cd1aSmrg # On systems with only ncurses 5, check for development version 945307cd1aSmrg # of ncurses. 955307cd1aSmrg use_ncurses6 965307cd1aSmrg ;; 975307cd1aSmrg esac 985307cd1aSmrg echo "** using tic from $VER" 995307cd1aSmrg # If this is 6.1.20180127 or later and using ABI 6, then it supports 1005307cd1aSmrg # entries larger than 4096 bytes (up to 32768). 1015307cd1aSmrg case "$VER" in 1025307cd1aSmrg *\ [7-9].*|*\ 6.[1-9].20[12][0-9]*) 1035307cd1aSmrg expect=" cols#100000," 1045307cd1aSmrg cat >"$MYTEMP"/fake.ti <<EOF 1055307cd1aSmrgfake|test 32-bit numbers, 1065307cd1aSmrg$expect 1075307cd1aSmrgEOF 1085307cd1aSmrg TERMINFO="$MYTEMP" $TIC_PROG $OPT "$MYTEMP"/fake.ti 2>/dev/null 1095307cd1aSmrg check=`TERMINFO="$MYTEMP" TERM=fake $INFOCMP_PROG -1 fake 2>/dev/null |grep "$expect"` 1105307cd1aSmrg test "x$check" = "x$expect" || BIG=no 1115307cd1aSmrg ;; 1125307cd1aSmrg *) 1135307cd1aSmrg BIG=no 1145307cd1aSmrg ;; 1155307cd1aSmrg esac 1165307cd1aSmrg if test "$BIG" = no 1175307cd1aSmrg then 1185307cd1aSmrg # Trim out the SGR 1006 feature, to keep "xterm-nrc" smaller 1195307cd1aSmrg # than 4096 bytes. 1205307cd1aSmrg echo "...this version does not support large terminal descriptions" 1215307cd1aSmrg PASS2=$MYTEMP/input 1225307cd1aSmrg sed -e 's/use=xterm+sm+1006,//' -e '/^[ ][ ]*$/d' "$PASS1" >"$PASS2" 1235307cd1aSmrg set "$PASS2" 1245307cd1aSmrg fi 1255307cd1aSmrg ;; 1265307cd1aSmrgesac 1275307cd1aSmrg 1285307cd1aSmrgecho "** $TIC_PROG $OPT $PASS1" 1295307cd1aSmrg$TIC_PROG $OPT "$PASS2" 2>"$STDERR" 1305307cd1aSmrgRET=$? 1315307cd1aSmrg 1325307cd1aSmrgsed -e "s%$PASS2%$PASS1%" "$STDERR" | \ 1335307cd1aSmrg@FGREP@ -v 'Unknown Capability' | \ 1345307cd1aSmrg@FGREP@ -v 'Capability is not recognized:' | \ 1355307cd1aSmrg@FGREP@ -v 'tic: Warning near line ' >&2 1365307cd1aSmrgrm -f "$STDERR" 1375307cd1aSmrg 1385307cd1aSmrgexit $RET 139