#!/bin/sh # Shell script to do passthrough print, dealing with unknown TERM, # unknown passthrough print codes, etc. # # Version 1.1: Prior version got errors on stty when piped # Version 1.2: Use 'printf' instead of 'echo -e' # Version 1.3: Identify shell to use in first line; use printf instead of echo -n # # Released to public domain by Rasmussen Software, Inc. # # To install: # Place it on UNIX(-like) system, in a directory in your PATH # Make it executable, with # chmod +x passprt # # To use: # Either pipe to it: # somecommand | passprt # or reference a file: # passprt somefile # if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then TERM=vt220 # TERM unknown; assume VT220 fi MC5=`tput mc5 2> /dev/null` # Code to turn on passthru MC4=`tput mc4 2> /dev/null` # Code to turn off passthru if [ "$MC4" = "" -o "$MC5" = "" ]; then # Are MC4, MC5 defined? case "$TERM" in [wW][yY]*) MC5=`printf "\033d#"`; # Wyse 50/60 MC4=`printf "\024"`;; [vV][iI][eE][wW]*) MC5=`printf "\0333"`; # Viewpoint MC4=`printf "\0334"`;; [vV][wW]*) MC5=`printf "\0333"`; # Vwpt MC4=`printf "\0334"`;; *) MC5=`printf "\033[?5i"`; # Other: assume ANSI style MC4=`printf "\033[?4i"`;; esac fi TTY=`tty <&2` # Determine tty name from # stdout SAVETTY=`stty -g < $TTY` # Save current stty settings stty onlcr < $TTY # Be sure LF gets CR added printf $MC5 # Turn on passthrough print cat $* # Output all files printf $MC4 # Turn off passthrough print stty $SAVETTY < $TTY # Restore stty settings