[BACK]Return to spell.ksh CVS log [TXT][DIR] Up to [local] / src / usr.bin / spell

Annotation of src/usr.bin/spell/spell.ksh, Revision 1.1

1.1     ! millert     1: #!/bin/ksh -
        !             2: #
        !             3: # $OpenBSD$
        !             4: #
        !             5: # Copyright (c) 2001 Todd C. Miller <Todd.Miller@courtesan.com>
        !             6: # All rights reserved.
        !             7: #
        !             8: # Redistribution and use in source and binary forms, with or without
        !             9: # modification, are permitted provided that the following conditions
        !            10: # are met:
        !            11: # 1. Redistributions of source code must retain the above copyright
        !            12: #    notice, this list of conditions and the following disclaimer.
        !            13: # 2. Redistributions in binary form must reproduce the above copyright
        !            14: #    notice, this list of conditions and the following disclaimer in the
        !            15: #    documentation and/or other materials provided with the distribution.
        !            16: # 3. The name of the author may not be used to endorse or promote products
        !            17: #    derived from this software without specific prior written permission.
        !            18: #
        !            19: # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
        !            20: # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
        !            21: # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
        !            22: # THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
        !            23: # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
        !            24: # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
        !            25: # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
        !            26: # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
        !            27: # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
        !            28: # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            29: #
        !            30: SPELLPROG=/usr/libexec/spellprog
        !            31: DICT=/usr/share/dict/words
        !            32: LOCAL_DICT=/usr/local/share/dict/words
        !            33: STOP=/usr/share/dict/stop
        !            34: LOCAL_STOP=/usr/local/share/dict/stop
        !            35: AMERICAN=/usr/share/dict/american
        !            36: BRITISH=/usr/share/dict/british
        !            37: LANG=$AMERICAN
        !            38: STOP_LANG=$BRITISH
        !            39: EXTRA=
        !            40: FLAGS=
        !            41: DEROFF="deroff -w"
        !            42: HISTFILE=
        !            43: TMP=`mktemp /tmp/spell.XXXXXXXX` || exit 1
        !            44: VTMP=
        !            45: USAGE="usage: spell [-biltvx] [-d list] [-h spellhist] [-s stop] [+extra_list] [file ...]"
        !            46:
        !            47: trap "rm -f $TMP $VTMP; exit 0" 0
        !            48:
        !            49: # Use local word/stop lists if they exist
        !            50: if [ -f $LOCAL_DICT ]; then
        !            51:        DICT="$DICT $LOCAL_DICT"
        !            52: fi
        !            53: if [ -f $LOCAL_STOP ]; then
        !            54:        STOP="$STOP $LOCAL_STOP"
        !            55: fi
        !            56:
        !            57: # getopts will treat +foo the same as -foo so we have to make a copy
        !            58: # of the args and quit the loop when we find something starting with '+'
        !            59: set -A argv $0 "$@"
        !            60: while test "${argv[$OPTIND]#+}" = "${argv[$OPTIND]}" && \
        !            61:     getopts "biltvxd:h:s:" c; do
        !            62:        case $c in
        !            63:        b)      LANG=$BRITISH
        !            64:                STOP_LANG=$AMERICAN
        !            65:                FLAGS[${#FLAGS[@]}]="-b"
        !            66:                ;;
        !            67:        i)      DEROFF="$DEROFF -i"
        !            68:                ;;
        !            69:        l)      DEROFF="delatex"
        !            70:                ;;
        !            71:        t)      DEROFF="detex"
        !            72:                ;;
        !            73:        v)      VTMP=`mktemp /tmp/spell.XXXXXXXX` || exit 1
        !            74:                FLAGS[${#FLAGS[@]}]="-v"
        !            75:                FLAGS[${#FLAGS[@]}]="-o"
        !            76:                FLAGS[${#FLAGS[@]}]="$VTMP"
        !            77:                ;;
        !            78:        x)      FLAGS[${#FLAGS[@]}]="-x"
        !            79:                ;;
        !            80:        d)      DICT="$OPTARG"
        !            81:                LANG=
        !            82:                ;;
        !            83:        s)      STOP="$OPTARG"
        !            84:                STOP_LANG=
        !            85:                LOCAL_STOP=
        !            86:                ;;
        !            87:        h)      HISTFILE="$OPTARG"
        !            88:                ;;
        !            89:        *)      echo "$USAGE" 1>&2
        !            90:                exit 1
        !            91:                ;;
        !            92:        esac
        !            93: done
        !            94: shift $(( $OPTIND - 1 ))
        !            95:
        !            96: while test $# -ne 0; do
        !            97:        case "$1" in
        !            98:                +*)     EXTRA="$EXTRA ${1#+}"
        !            99:                        shift
        !           100:                        ;;
        !           101:                *)      break
        !           102:                        ;;
        !           103:        esac
        !           104: done
        !           105:
        !           106: # Any parameters left are files to be checked, pass them to deroff
        !           107: DEROFF="$DEROFF $@"
        !           108:
        !           109: if [ -n "$HISTFILE" ]; then
        !           110:        $DEROFF | sort -u | $SPELLPROG -o $TMP $STOP $STOP_LANG | \
        !           111:            $SPELLPROG ${FLAGS[*]} $DICT $LANG $EXTRA | sort -u -k1f - $TMP | \
        !           112:            tee -a $HISTFILE
        !           113:        who -m >> $HISTFILE
        !           114: else
        !           115:        $DEROFF | sort -u | $SPELLPROG -o $TMP $STOP $STOP_LANG | \
        !           116:            $SPELLPROG ${FLAGS[*]} $DICT $LANG $EXTRA | sort -u -k1f - $TMP
        !           117: fi
        !           118:
        !           119: if [ -n "$VTMP" ]; then
        !           120:        sort -u -k2f -k1 $VTMP
        !           121: fi
        !           122:
        !           123: exit 0