#!/usr/local/bin/perl 'di'; 'ig00'; ;# ;# termfix: fix termcap and execute command ;# ;# Copyright (c) 1992-1993 Kazumasa Utashiro ;# Software Research Associates, Inc. ;# 1-1-1 Hirakawa-cho, Chiyoda-ku, Tokyo 102, Japan ;# ;# Original on 24 Mar 1992 ;# ;; $rcsid = '$Id: termfix,v 1.4 1993/02/17 10:01:53 utashiro Exp $';#' ;# ;# EXAMPLES ;# termfix md@ man 5 termcap # cancel "md" ;# termfix tite@ vipw # cancel "ti" and "te" ;# termfix 'so=\E[7m' man 5 termcap # set "so" ;# termfix usue=sose man 5 termcap # set "us,ue" same as "so,se" ;# termfix usue^sose man 5 termcap # exchange "us,ue" and "so,se" ;# ;; $myname = ('termfix', split('/', $0)); ;; $usage = <<_; Usage: $myname [xx=...] [xx=yy] [xx^yy] [xx\@] [command] xx=... set xx to ... xx=yy set xx to yy xx^yy exchange xx and yy xx\@ cancel xx $rcsid _ while ($_ = $ARGV[$[], s/^-(.+)$/$1/ && shift) { if (s/[fd]//) { eval "\$opt_$&++"; redo; } if (s/H//) { exec "nroff -man $0|".($ENV{'PAGER'}||'more')." -s"; } if (s/v//) { print "$rcsid\n"; exit 0; } if (s/.//) { print $usage; exit($& ne 'h'); } } ($TERM, $TC) = split(/\s+/, scalar(`tset -IQS`), 2) if $opt_f || !($TC = $ENV{'TERMCAP'}) || $TC =~ m|^/|; $TC =~ s/:\s*:/:/g; $OTC = $TC; study $OTC; while ($_ = $ARGV[$[]) { if (/^(\w\w)\@$/) { $TC =~ s/:$1[^:]*:/:/; } elsif (($a, $b) = /^(\w\w)=(\w\w)$/) { $TC =~ s/$a([=#])[^:]*/$a$1$new/ if ($new) = ($OTC =~ /$b[=#]([^:]*)/); } elsif (($a, $b) = /^(\w\w)=(.*)$/) { $TC =~ s/$a([=#])[^:]*/$a$1$b/; } elsif (/^(\w\w)\^(\w\w)$/) { splice(@ARGV, 1, 0, "$1=$2", "$2=$1"); } elsif (/^((\w\w){2,})([=@\^])((\w\w)*)$/) { $L = $1; $R = $4; $op = $3; $r = ''; last if $op eq '@' && $R; splice(@ARGV, 1, 0, grep((($R =~ s/^..//) && ($r = $&), s/$/$op$r/), $L =~ /../g)); } else { last; } print STDERR $_, "\n" if $opt_d; shift; } if (@ARGV) { $ENV{'TERMCAP'} = $TC; exec(@ARGV), die "$ARGV[0]: $!\n"; } else { print $TC; print "\n" unless $TC =~ /\n$/; } exit 0; ###################################################################### .00; # finish .ig 'di \" finish diversion--previous line must be blank .nr nl 0-1 \" fake up transition to first page again .nr % 0 \" start at page 1 ';<<'.ex'; #__END__ ############# From here on it's a standard manual page # .de XX .ds XX \\$2 .. .XX $Date: 1993/02/17 10:01:53 $ .TH TERMFIX 1 \*(XX .AT 3 .SH NAME termfix \- fix termcap and execute command .SH SYNOPSIS .B termfix [ .I options ] [ .I command ] .SH DESCRIPTION .I Termfix fixes current termcap temporarily and execute command specified in arguments. If no command is supplied, it just prints new capability. .PP There are several different style options. .IP "xx=sequence" Specify .I sequence to capability .IR xx . Next example sets sequence ``\eE[7m'' to .I so and execute man command. .nf termfix 'so=\eE[7m' man 5 termcap .fi Sequence should not be two alphabetic characters. .IP "xx=yy" This option sets .I xx capability same as .IR yy 's. So next example sets .I md capability same as .IR so . .nf termfix md=so man 5 termcap .fi Referenced capability keeps original value after any operations. .IP "xx^yy" Exchange .I xx and .I yy capabilities. Next example exchanges .I so and .I us capabilities. .nf termfix so^us man 5 termcap .fi .IP "xx@" Disable .I xx capability. Next example disables .I te capability. .nf termfix ti@ te@ man 5 termcap .fi .PP If you want to replace TERMCAP environment variable with new one, set the output of .I termfix to TERMCAP variable like this: .nf setenv TERMCAP "`termfix te@`" .fi .PP Multiple capabilities can be set in one operation on every cases. .ne 5 .nf termfix mdme=sose (md=so me=se) termfix sose^usue (so^us se^ue) termfix mdso=us mese=ue (md=us so=us me=ue se=ue) termfix tite@ (ti@ te@) .fi If number of right values are less than left values, last right value is used repeatedly. .SH AUTHOR Kazumasa Utashiro .br Software Research Associates, Inc. .br 1-1-1 Hirakawa-cho, Chiyoda-ku, Tokyo 102, Japan .SH "SEE ALSO" tset(1), termcap(5) .ex