RAW I/O ISSUE
============
There seems to be a problem unique to ksh93 when reading raw data from the
screen. If the following script is run
in an X11 xterm(1) window using ksh93 the window locks up until the process is
killed. The purpose of the script is to read the
current X11 font selected by the xterm(1) window. Over the years this script
has been on at least a dozen Unix
variants, and many Linux/OpenBSD/, etc... OSes. It has worked with ksh88,
pdksh, and bash. It is representative of
a large batch of scripts that control xterm(1) windows from the CLI (command
line interface) and do formatting
similar to the ncurses-based utilities like display(1).
1) it would be nice if ksh93 could run this as-is, as the scripts that use
something like the following example have
been widely distributed for many years ( the xterm-related ones are at
http://home.comcast.net/~urbanjost/CLONE/UNIX_SCRIPTS/scripts_xterm/index.html
if anyone is interested).
2) if ksh93 cannot respond to the RAWGET() function as-is, is there a reliable
way already available in ksh93 to do so ( not including
creating a new builtin)?
ANYONE KNOW OF A SCREEN-BASED GETOPTS?
========================================
If anyone remembers CDC NOS CCL, they may remember that any script could be
called interactively in line-mode or in screen mode using
something called the TDU (terminal definition utility). Think of it as having
had a super-getopts (1) that let you define rules for allowable input values,
default values, a prompt, and help text as well as parsing your parameters. I
have such a (non-open) program for UNIX; but was thinking of
updating it and making it into an open built-in for ksh93. Does anyone know
if anything like this is already available as open source?
TEST SCRIPT
===========
This script, as you can see, has had problems on different systems depending on
whether they were
SYS-V or BSD-derived and so on. I left the dirty details there (this script
dates back to at least 1991, and probably
earlier)
#!/bin/ksh
# @(#) getfont -- get current font selected by X11 xterm(1)
unset PS1
##################################
myecho(){
#printf "$*" >> /dev/tty
printf "$*"
}
##################################
mywrite(){
printf "$*\n"
}
##################################
esc="" # actual escape (esc) character (ctrl-[)
bel="" # actual bell (bel) character (ctrl-g)
#SUF='\c'
SUF=''
prefix="${esc}["
export esc bel SUF prefix
##################################
RAWGET(){
#exec >/dev/tty </dev/tty
exec </dev/tty
old=`stty -g`
#stty -cread
#stty raw -echo min 0 time 5
stty raw -echo min 0 time 1
myecho "${*}" >/dev/tty
IFS=";${bel}" read A B C D
while read ACHAR
do
:
done </dev/tty
flush=`dd if=/dev/tty bs=1 count=1 2>/dev/null</dev/tty`
stty $old
#echo "VALUES @ $A @ $B @ $C @ $D @" | cat -v -e -t 1>&2
}
##################################
GETFONT(){
RAWGET "${esc}]50;?${bel}" >/dev/tty
fontname="$B"
}
##################################
GETFONT
echo "Current font is $B"
##################################
exit
##################################
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users