#!/bin/sh
# Usage: mailattach [-s subject] to-address file1 ...
#
argsreq=2
if [ $# -ge 1 ]; then
    if [ "X$1" = "X-s" ]; then
	argsreq=4
    fi
fi
if [ $# -lt $argsreq ]; then
    echo Usage: $0 [-s subject] to-address file1 ...
    exit 1
else
    if [ "X$1" = "X-s" ]; then
        subject="$2"
        shift; shift
    fi
    to=$1
    shift
fi
subject=${subject-"Files $*"}
(for i in $*; do echo "\\attach{$i} `basename $i`"; done) | \
    tnextmail -s "$subject" $to
