Thorsten Glaser wrote:
> any csh guru out here who wants to help rewriting
> src/usr.bin/vgrind/vgrind.sh in ksh?

I don't know what it does, and I didn't run it, but it should be
pretty close to something working. I assume you can fix the rest.

Remove the -x in the shebang if you are content.

Good luck with it :-)

#!/bin/sh -x
#
#       $Id$
#
# Copyright (c) 2005 Han Boetes <[EMAIL PROTECTED]>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

# Allow troff to be overridden
TROFF=${TROFF:=troff}

name=${0##*/}
vf=/usr/libexec/vfontedpr
tm=/usr/share/tmac

unset voptions options files f head

while [ $# -gt 0 ]; do
    case $1 in
        -f)
            f=filter
            options="$options $1"
            ;;
        -t)
            voptions="$voptions -t"
            ;;
        -o*)
            voptions="$voptions $1"
            ;;
        -W)
            voptions="$voptions -W"
            ;;
        -d)
            if [ -z "$2" ]; then
                echo "$name: option \`-d' must have argument" >&2
                exit 1
            else
                options="$options $1 $2"
                shift
            fi
            ;;
        -h)
            if [ -z "$2" ]; then
                echo "$name: option -h must have argument" >&2
                exit 1
            else
                head="$2"
                shift
            fi
            ;;
        -*)
            echo "$name: invalid option \`$1'" >&2
            exit 1
            ;;
        *)
            files="$files $i"
            ;;
    esac
    shift
done

if [ -r index ] then
    echo > nindex
    for i in $files; do
        # make up a sed delete command for filenames being careful
        # about slashes.
        echo "? $i ?d" | sed -e "s:/:\\/:g" -e "s:?:/:g" >> nindex
    done
    sed -f nindex index > xindex
    if [ "$f" = filter ]; then
        if [ -n "$head" ]; then
            $vf $options -h "$head" $files | cat $tm/tmac.vgrind -
        else
            $vf $options $files | cat $tm/tmac.vgrind -
        fi
    else
        if [ -n "$head" ]; then
            $vf $options -h "$head" $files |
            $TROFF -rx1 $voptions -i -mvgrind 2>> xindex
        else
            $vf $options $files |
            $TROFF -rx1 $voptions -i -mvgrind 2>> xindex
        fi
    fi
    sort -df +0 -2 xindex > index
    rm nindex xindex
else
    if [ "$f" = filter ]; then
        if [ -n "$head" ]; then
            $vf $options -h "$head" $files | cat $tm/tmac.vgrind -
        else
            $vf $options $files | cat $tm/tmac.vgrind -
        fi
    else
        if [ -n "$head" ]; then
            $vf $options -h "$head" $files | $TROFF -i $voptions -mvgrind
        else
            $vf $options $files | $TROFF -i $voptions -mvgrind
        fi
    fi
fi




# Han

Reply via email to