#!/usr/bin/ksh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # spell program # B_SPELL flags, D_SPELL dictionary, F_SPELL input files, H_SPELL history, # S_SPELL stop, V_SPELL data for -v # L_SPELL sed script, I_SPELL -i option to deroff setvar PATH = "/usr/lib/spell:/usr/bin:$PATH" setvar SPELLPROG = '/usr/lib/spell/spellprog' setvar H_SPELL = ${H_SPELL:-/var/adm/spellhist} setvar V_SPELL = '/dev/null' setvar F_SPELL = '' setvar FT_SPELL = '' setvar B_SPELL = '' setvar L_SPELL = ""/usr/bin/sed -e \"/^[.'].*[.'][ ]*nx[ ]*\/usr\/lib/d\" -e \"/^[.'].*[.'][ ]*so[ ]*\/usr\/lib/d\" -e \"/^[.'][ ]*so[ ]*\/usr\/lib/d\" -e \"/^[.'][ ]*nx[ ]*\/usr\/lib/d\" "" setvar LOCAL = '' # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp # for this process's temporary files. We set up a trap to remove the # directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, and # SIGTERM. # proc mktmpdir { setvar tmpdir = "/tmp/spell.$Pid" trap "/usr/bin/rm -rf $tmpdir; exit" 0 1 2 13 15 /usr/bin/mkdir -m 700 $tmpdir || exit 1 } mktmpdir # figure out whether or not we can use deroff if test -x /usr/bin/deroff { setvar DEROFF = ""deroff \$I_SPELL"" } else { setvar DEROFF = ""cat"" } # Filter out + arguments that are incorrectly handled by getopts set -A args xxx @ARGV while [ x${args[$OPTIND]#+} = x${args[$OPTIND]} ] && getopts ablvxi A { match $A { with v if test -r /bin/pdp11 && /bin/pdp11 { gettext "spell: -v option not supported on pdp11\n" 1>&2 setvar EXIT_SPELL = ""exit 1"" } else { setvar B_SPELL = ""$B_SPELL -v"" setvar V_SPELL = "$tmpdir/spell.$Pid" } with b setvar D_SPELL = ${LB_SPELL:-/usr/lib/spell/hlistb} setvar B_SPELL = ""$B_SPELL -b"" with x setvar B_SPELL = ""$B_SPELL -x"" with l setvar L_SPELL = ""cat"" with i setvar I_SPELL = ""-i"" with ? gettext "Usage: spell [-bvxli] [+local_file] [files...]\n" 1>&2 exit 1 } } shift $(($OPTIND - 1)) for A in [$ifsjoin(ARGV)] { match $A { with +* if test $FIRSTPLUS = "+" { gettext "spell: multiple + options in spell, all but the last are ignored" 1>&2 }; setvar FIRSTPLUS = ""$FIRSTPLUS"+" if setvar LOCAL = $(expr $A : '+\(.*\)' ) { if test ! -r $LOCAL { printf "$(gettext 'spell: Cannot read %s)\n" $LOCAL 1>&2; setvar EXIT_SPELL = ""exit 1""; } } else { gettext "spell: Cannot identify local spell file\n" 1>&2; setvar EXIT_SPELL = ""exit 1""; } with * setvar FT_SPELL = ""$FT_SPELL $A"" if test -r $A { setvar F_SPELL = ""$F_SPELL $A"" } else { printf "$(gettext 'spell: Cannot read file %s)\n" $A 1>&2 } } } ${EXIT_SPELL:-:} if test "x$FT_SPELL" != "x$F_SPELL" && test "x$F_SPELL" = "x" { exit 1 } shell {cat $F_SPELL; printf "\n";} | eval $L_SPELL |\ eval $DEROFF' |\ LC_ALL=C' /usr/bin/tr -cs "[A-Z][a-z][0-9]\'\&\.\,\;\?\:" "[\012*]" |\ /usr/bin/sed '1,$s/^[^A-Za-z0-9]*//' | /usr/bin/sed '1,$s/[^A-Za-z0-9]*$//' |\ /usr/bin/sed -n "/[A-Za-z]/p" | /usr/bin/sort -u +0 |\ $SPELLPROG ${S_SPELL:-/usr/lib/spell/hstop} 1 |\ $SPELLPROG $B_SPELL ${D_SPELL:-/usr/lib/spell/hlista} $V_SPELL |\ comm -23 - ${LOCAL:-/dev/null} |\ tee -a $H_SPELL /usr/bin/who am i >>$H_SPELL 2>/dev/null match $V_SPELL { with /dev/null exit } /usr/bin/sed '/^\./d' $V_SPELL | /usr/bin/sort -u +1f +0