The R Project SVN R

Rev

Rev 7296 | Rev 7478 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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

: ${R_HOME=R_HOME_DIR}
export R_HOME

R_BINARY="R.X11"

# Default printer paper size
# Choose one of the following:
# R_PAPERSIZE="a4"
# R_PAPERSIZE="letter"
# R_PAPERSIZE="none"
: ${R_PAPERSIZE=@R_PAPERSIZE@}
export R_PAPERSIZE

# Default print command
# Choose one of the following:
# R_PRINTCMD="lpr"
# R_PRINTCMD="lp"
: ${R_PRINTCMD=@R_PRINTCMD@}
export R_PRINTCMD

# Default TeXMF stuff
R_LATEXCMD=${R_LATEXCMD:-${LATEX:-@LATEX@}}
R_DVIPSCMD=${R_DVIPSCMD:-${DVIPS:-@DVIPS@}}
R_MAKEINDEXCMD=${R_MAKEINDEX:-${MAKEINDEX:-@MAKEINDEX@}}
export R_LATEXCMD R_DVIPSCMD R_MAKEINDEXCMD
: ${R_RD4DVI=@R_RD4DVI@}
: ${R_RD4PDF=@R_RD4PDF@}
export R_RD4DVI R_RD4PDF

# Default zip/unzip commands
: ${R_UNZIPCMD=@R_UNZIPCMD@}
: ${R_ZIPCMD=@R_ZIPCMD@}
export R_UNZIPCMD R_ZIPCMD

# Default environment file -- used if there's none in current
: ${R_ENVIRON="${HOME}/.Renviron"}
USE_R_ENVIRON=true

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

If a long option shows an argument as mandatory, then it is mandatory
for the equivalent short option also.

Options:
  -g, --gnome       Run the gnome binary
  --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
  --no-environ          Don't read the .Renviron or ~/.Renviron files
  --vanilla     Combine --no-save, --no-restore, --no-site-file,
            --no-init-file, and --no-environ
  --vsize=N             Set vector heap size to N bytes; \`4M' = 4 MegaB
  --nsize=N             Set number of cons cells to N
  -h, --help            Print short help message and exit
  -q, --quiet           Don't print startup message
  --silent              Same as --quiet
  --slave               Make R run as quietly as possible
  --version             Print version info and exit
  --verbose             Print more information about progress
  -d, --debugger=NAME   Run R through debugger NAME

Commands:
  RHOME         Give R's home directory and exit
  BATCH         Run batch job
  COMPILE       Compile files for use with R
  INSTALL       Install add-on packages
  REMOVE        Remove add-on packages
  SHLIB         Build shared library for dynamic loading

  Please use \`R command --help' to obtain further information.

Rcommands:
  Rdconv        Convert Rd format to various other formats
  Rd2dvi        Convert Rd format to DVI
  Rd2txt        Convert Rd format to pretty text
  Rdindex       Extract index information from Rd files
  Sd2Rd         Convert S documentation to Rd format
  build         Build add-on packages
  check         Check add-on packages

  Please use \`R CMD Rcommand --help' to obtain further information.

Report bugs to <R-bugs@lists.r-project.org>."

# Argument loop
args=
debugger=
while test -n "${1}"; do
  case ${1} in
    RHOME)
      echo ${R_HOME}; exit 0 ;;
    BATCH|COMPILE|INSTALL|REMOVE|SHLIB)
      cmd="${1}"; shift; exec sh "${R_HOME}/bin/${cmd}" "${@}" ;;
    CMD)
      shift; PATH="${R_HOME}/bin:${PATH}" exec "${@}" ;;
    -g|--gnome)
      R_BINARY="R.gnome" ;;
    -d)
      debugger="${2}"; shift ;;
    --debugger=*)
      debugger=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
    --no-environ)
      USE_R_ENVIRON=false ;;
    --vanilla)
      args="${args} ${1}"
      USE_R_ENVIRON=false ;;
    -h|--help)
      echo "${USAGE_MSG}"; exit 0 ;;
    --version)
      exec ${R_HOME}/bin/${R_BINARY} --version ;;
    *)
      args="${args} ${1}" ;;
  esac
  shift
done

# Startup
if ${USE_R_ENVIRON}; then # use the one in current dir, or default
  if [ -r ./.Renviron ]; then
    . ./.Renviron
  else
    [ -r ${R_ENVIRON} ] && . ${R_ENVIRON}
  fi
fi

if test -z "${debugger}"; then
  exec ${R_HOME}/bin/${R_BINARY} @R_BATCHSAVE@ ${args}
else
  if test -n "${args}"; then
    echo "*** Further command line arguments (\`${args}') disregarded"
    echo "*** (maybe use \`run ${args}' from *inside* ${debugger})"
    echo ""
  fi
  exec ${debugger} ${R_HOME}/bin/${R_BINARY}
fi

### Local Variables: ***
### mode: sh ***
### sh-indentation: 2 ***
### End: ***