#!/bin/sh
# Shell wrapper for R executable.

RHOME=/opt/SDGrdevel/19990209/lib/R
export RHOME

ARG="$1"
case "${ARG}" in
    RHOME)
	echo ${RHOME}; exit 0 ;;
    CMD)
	shift; PATH="${PATH}:${RHOME}/bin" exec "$@" ;;
    BATCH|COMPILE|INSTALL|REMOVE|SHLIB)
	shift; exec sh "${RHOME}/bin/${ARG}" "$@" ;;
    -d|--debugger)
	exec "$2" ${RHOME}/bin/R.binary ;;
    -h|--help|-\?)
	cat <<_EOF_

Usage:  R [OPTIONS] [< INFILE] [> OUTFILE]
   or   R command      [arguments]
   or   R CMD Rcommand [arguments]

Options:
  --save                    Do save data sets at the end of the session.
  --no-save                 Don't save them.
  --restore                 Do restore previously saved data sets at startup.
  --no-restore              Don't restore them.
  --no-readline             Don't use readline for command-line editing.
  --no-site-file            Don't read the site-wide Rprofile.
  --no-init-file            Don't read the .Rprofile or ~/.Rprofile files.
  --vanilla		    = --no-save, no-restore, no-site-file, no-init-file
  --vsize N                 Set the vector heap size to N (>= 1)  megabytes.
  --nsize N                 Set the number of cons cells to N (>= 200000).
  -h, --help, -?            Print short help message and exit.
  -q, --quiet, --silent     Make R run as quietly as possible.
  --version                 Print version info and exit.
  --verbose                 Print more information about progress.
  -d NAME, --debugger NAME  Run R through debugger NAME.

Commands:
  RHOME				Give R's home directory
  BATCH infile [ outfile ]	Run Batch job
  COMPILE|INSTALL|REMOVE|SHLIB  Package management & dyn.load compilation

Rcommands:
  Rdconv
  Rdindex, Sd2Rd
  Rd2dvi, Rd2txt
   ...

Report bugs to R-bugs@biostat.ku.dk."

_EOF_
	exit 0 ;;
esac

# Default Printer Paper Size
# Choose one of the following
# R_PAPERSIZE="a4"
# R_PAPERSIZE="letter"
# R_PAPERSIZE="none"
R_PAPERSIZE=${R_PAPERSIZE-a4}
export R_PAPERSIZE

# Default Print Command
# Choose one of the following
# R_PRINTCMD="lpr"
# R_PRINTCMD="lp"
R_PRINTCMD=${R_PRINTCMD-lpr}
export R_PRINTCMD

LATEX=${LATEX-/opt/TeX/bin/latex}
DVIPS=${DVIPS-/opt/TeX/bin/dvips}
export LATEX DVIPS

exec ${RHOME}/bin/R.binary  "$@"
