#! /bin/sh
: &&O='cd .' || exec /bin/sh "$0" $argv:q # we're in a csh, feed myself to sh
$O || exec /bin/sh "$0" "$@"		  # we're in a buggy zsh
#########################################################################
#	newdoxcmd 	To send of X-Command mails			#
# based on:								#
#	doxcommand	To send of X-Command mails			#
#									#
#	Created by S.R. van den Berg, The Netherlands			#
#									#
#	Customised by Alan Schwartz
#########################################################################

#
# Edit the following three definitions to suit your list
#

listrequest=yourlist-request@some.where
maintainer=yourname@some.where
header=X-Command

#
# In a standard environment you shouldn't need to make any changes below
# this line
#

test=test			# /bin/test
echo=echo			# /bin/echo
sendmail=/usr/lib/sendmail	# /usr/lib/sendmail

$test $# = 0 && $echo "Usage: $0 command [argument] ..." 1>&2 &&
 exit 64

command="$1"
shift

# Allow for abbreviations or misspellings (people are lazy by nature :-)

case "$command" in
  su*) command=subscribe ;;
  u*) command=unsubscribe ;;
  c*) command=checkdist ;;
  showd*|sd*|shd*) command=showdist ;;
  showl*|sl*|shl*) command=showlog ;;
  w*) command=wipelog ;;
  v*) command=version ;;
  h*) command=help ;;
  i*) command=info ;;
  *) $echo "Unknown command, use any of the following:" 1>&2
     $echo "subscribe, unsubscribe, checkdist, showdist, showlog," 1>&2
     $echo "wipelog, version, help or info." 1>&2
     exit 64
esac

$echo "Enter the list's password:"
read password

$sendmail $listrequest <<HERE
To: $listrequest
$header: $maintainer $password $command $*
Subject: X-Processed: $command $* of <$listrequest>


HERE

$echo "Sent to $listrequest: $command $*"