version.sh revision a5ae21e4
1a5ae21e4Smrg#!/bin/sh 2a5ae21e4Smrg# $XTermId: version.sh,v 1.1 2020/04/25 20:47:48 tom Exp $ 3a5ae21e4Smrg# ----------------------------------------------------------------------------- 4a5ae21e4Smrg# this file is part of xterm 5a5ae21e4Smrg# 6a5ae21e4Smrg# Copyright 2020 by Thomas E. Dickey 7a5ae21e4Smrg# 8a5ae21e4Smrg# All Rights Reserved 9a5ae21e4Smrg# 10a5ae21e4Smrg# Permission is hereby granted, free of charge, to any person obtaining a 11a5ae21e4Smrg# copy of this software and associated documentation files (the 12a5ae21e4Smrg# "Software"), to deal in the Software without restriction, including 13a5ae21e4Smrg# without limitation the rights to use, copy, modify, merge, publish, 14a5ae21e4Smrg# distribute, sublicense, and/or sell copies of the Software, and to 15a5ae21e4Smrg# permit persons to whom the Software is furnished to do so, subject to 16a5ae21e4Smrg# the following conditions: 17a5ae21e4Smrg# 18a5ae21e4Smrg# The above copyright notice and this permission notice shall be included 19a5ae21e4Smrg# in all copies or substantial portions of the Software. 20a5ae21e4Smrg# 21a5ae21e4Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22a5ae21e4Smrg# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23a5ae21e4Smrg# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24a5ae21e4Smrg# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 25a5ae21e4Smrg# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26a5ae21e4Smrg# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27a5ae21e4Smrg# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28a5ae21e4Smrg# 29a5ae21e4Smrg# Except as contained in this notice, the name(s) of the above copyright 30a5ae21e4Smrg# holders shall not be used in advertising or otherwise to promote the 31a5ae21e4Smrg# sale, use or other dealings in this Software without prior written 32a5ae21e4Smrg# authorization. 33a5ae21e4Smrg# ----------------------------------------------------------------------------- 34a5ae21e4Smrg# Demonstrate version-string from xterm #354 35a5ae21e4Smrg 36a5ae21e4SmrgESC="" 37a5ae21e4SmrgCMD='/bin/echo' 38a5ae21e4SmrgOPT='-n' 39a5ae21e4SmrgSUF='' 40a5ae21e4SmrgTMP=/tmp/xterm$$ 41a5ae21e4Smrgeval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null 42a5ae21e4Smrg( test ! -f $TMP || test -s $TMP ) && 43a5ae21e4Smrgfor verb in printf print ; do 44a5ae21e4Smrg rm -f $TMP 45a5ae21e4Smrg eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null 46a5ae21e4Smrg if test -f $TMP ; then 47a5ae21e4Smrg if test ! -s $TMP ; then 48a5ae21e4Smrg CMD="$verb" 49a5ae21e4Smrg OPT= 50a5ae21e4Smrg SUF='\c' 51a5ae21e4Smrg break 52a5ae21e4Smrg fi 53a5ae21e4Smrg fi 54a5ae21e4Smrgdone 55a5ae21e4Smrgrm -f $TMP 56a5ae21e4Smrg 57a5ae21e4Smrgexec </dev/tty 58a5ae21e4Smrgold=`stty -g` 59a5ae21e4Smrgstty raw -echo min 0 time 5 60a5ae21e4Smrg 61a5ae21e4Smrg$CMD $OPT "${ESC}[>0q${SUF}" > /dev/tty 62a5ae21e4Smrgread version 63a5ae21e4Smrg 64a5ae21e4Smrgstty $old 65a5ae21e4Smrgecho "$version" |cat -v 66