C=$SHOME/cmd
BATCH=yes; export BATCH
case $1 in -e) flags=-e; shift;; esac
case $# in
0)
	trap "" 2
	(echo "invisible(options(echo=T))";
		$C/report.in $flags )|S 2>&1 |$C/report.out
	;;
1)
	trap "" 2
	(echo "invisible(options(echo=T))";
		$C/report.in $flags <$1 ) |S 2>&1|$C/report.out
	;;
2)
	echo "REPORT will run in batch: input from file $1, output on file $2."
	sleep 5	# chance for user to abort
	nohup sh -c "(echo 'invisible(options(echo=T))'; $C/report.in $flags <$1) | S 2>&1 | $C/report.out" >$2 &
	;;
*)	echo "Usage:

S REPORT input output     # batch execution
S REPORT input >output    # wait for completion 
S REPORT <input >output   # wait for completion

The last two forms can be used in pipelines."
	;;
esac
