#!/bin/sh
# @(#)log 1.0 89/06/10 Maarten Litmaath
#
###	logerrs - save error messages in a logfile, duplicate them on stderr
###	Usage: logerrs error-logfile command
##
## Example:
##
##	$ cat foo
##	hello world
##	$ log errors cat foo bar
##	hello world
##	bar: No such file or directory
##	$ cat errors
##	bar: No such file or directory
##	$ log errors 'Pointer Addition'
##	$ cat errors
##	bar: No such file or directory
##	Pointer Addition: Protocol not supported
##	$
# "Your password [should be] like your |Maarten Litmaath @ VU Amsterdam:
#      toothbrush." (Don Alvarez)      |maart@cs.vu.nl, mcvax!botter!maart

case $# in
[012])
	echo "Usage: `basename $0` <error logfile> <command>" >&2
	exit 1
	;;
esac

ERRLOG="$1"
shift

exec 3>&1
"$@" 2>&1 >&3 | tee -a "$ERRLOG" >&2
