vgrind.ksh revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# vgrind
# Copyright (c) 1999-2000 by Sun Microsystems, Inc.
# All rights reserved.
#
# ident "%Z%%M% %I% %E% SMI"
#
# Copyright (c) 1980 Regents of the University of California.
# All rights reserved. The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
# This is a rewrite in ksh of the command originally written in
# csh whose last incarnation was:
# vgrind.csh 1.16 96/10/14 SMI; from UCB 5.3 (Berkeley) 11/13/85
#
# Definitions the user can override
# Internal processing of options
args=""
dpostopts="-e 2"
files=""
lpopts=""
troffopts="-t"
filter=0
uselp=1
usedpost=1
pspec=0
tspec=0
twospec=0
printer=""
if [ -t 1 ] ; then
fi
# Process command line options
while getopts ":2d:fh:l:no:P:s:tT:wWx" opt ; do
+*)
exit 1
;;
"?")
exit 1
;;
2)
dpostopts="$dpostopts -p l"
usedpost=1
twospec=1
;;
d)
if ! [ -r $OPTARG ] ; then
/usr/bin/printf "`/usr/bin/gettext TEXT_DOMAIN 'vgrind: -%s %s: file not readable'`\n" "$opt" "$OPTARG" >&2
exit 1
fi
;;
f)
filter=1
;;
h)
;;
l)
;;
n)
;;
o)
;;
P)
uselp=1
usedpost=1
pspec=1
;;
s)
;;
T)
;;
t)
uselp=0
usedpost=0
tspec=1
;;
W)
# Do nothing with this switch
;;
w)
;;
x)
;;
*)
;;
esac
if [ "$opt" = ":" ] ; then
/usr/bin/printf "`/usr/bin/gettext TEXT_DOMAIN 'vgrind: missing argument to option %s'` \n" "-$OPTARG" >&2
exit 1
fi
done
for x in "$@" ; do
done
shift $#
/usr/bin/printf "`/usr/bin/gettext TEXT_DOMAIN 'vgrind: option -f is incompatible with -2 and -P'`\n" >&2
exit 1
fi
exit 1
fi
/usr/bin/printf "`/usr/bin/gettext TEXT_DOMAIN 'vgrind: option -t is incompatible with -2 and -P'`\n" >&2
exit 1
fi
# Do some reasoning about whether to print
# If we want to print
if [ -z "$printer" ] ; then
# If "-P" was not specified
defaultprinter=`LC_ALL=C /usr/bin/lpstat -d | /usr/bin/sed -e "s/no system default destination//" 2>/dev/null`
if [ -n "$defaultprinter" ] ; then
defaultprinter=`echo $defaultprinter | \
fi
# If stdout is not re-directed
if [ -z "$defaultprinter" ] ; then
uselp=0
else
fi
else
# stdout is redirected - assume it is for further processing of
# postscript output.
uselp=0
fi
fi
fi
lp)
;;
lpr)
;;
*)
exit 1
;;
esac
fi
# Implementation note: In the following, we use "eval" to execute the
# command in order to preserve spaces which may appear in the -h option
# argument (and possibly in file names).
else
if [ -r index ] ; then
# Removes any entries from the index that come from the files we are
# processing.
echo > nindex
done
# Now process the input.
# (! [$filter -eq 1])
cmd="$cmd | $troff -rx1 $troffopts -i $macros - 2>> xindex"
cmd="$cmd | $dpost $dpostopts"
fi
fi
eval $cmd
else
# (! [ -r index ])
cmd="$cmd | $troff -i $troffopts $macros -"
cmd="$cmd | $dpost $dpostopts"
fi
fi
eval $cmd
fi
fi