1#!@R_SHELL@ 2# Shell wrapper for R executable. 3 4R_HOME_DIR= 5if test "${R_HOME_DIR}" = "@prefix@/@LIBnn@/R"; then 6 case "@R_OS@" in 7 linux*) 8 run_arch=`uname -m` 9 case "$run_arch" in 10 x86_64|mips64|ppc64|powerpc64|sparc64|s390x) 11 libnn=lib64 12 libnn_fallback=lib 13 ;; 14 *) 15 libnn=lib 16 libnn_fallback=lib64 17 ;; 18 esac 19 if [ -x "@prefix@/${libnn}/R/bin/exec/R" ]; then 20 R_HOME_DIR="@prefix@/${libnn}/R" 21 elif [ -x "@prefix@/${libnn_fallback}/R/bin/exec/R" ]; then 22 R_HOME_DIR="@prefix@/${libnn_fallback}/R" 23 ## else -- leave alone (might be a sub-arch) 24 fi 25 ;; 26 esac 27fi 28 29if test -n "${R_HOME}" && \ 30 test "${R_HOME}" != "${R_HOME_DIR}"; then 31 echo "WARNING: ignoring environment value of R_HOME" 32fi 33R_HOME="${R_HOME_DIR}" 34export R_HOME 35R_SHARE_DIR="${R_HOME_DIR}/share" 36export R_SHARE_DIR 37R_INCLUDE_DIR="${R_HOME_DIR}/include" 38export R_INCLUDE_DIR 39R_DOC_DIR="${R_HOME_DIR}/doc" 40export R_DOC_DIR 41 42# Since this script can be called recursively, we allow R_ARCH to 43# be overridden from the environment. 44# This script is shared by parallel installs, so nothing in it should 45# depend on the sub-architecture except the default here. 46: ${R_ARCH=@R_ARCH@} 47 48usage=" 49Usage: R [options] [< infile] [> outfile] 50 or: R CMD command [arguments] 51 52Start R, a system for statistical computation and graphics, with the 53specified options, or invoke an R tool via the 'R CMD' interface. 54 55Options: 56 -h, --help Print short help message and exit 57 --version Print version info and exit 58 --encoding=ENC Specify encoding to be used for stdin 59 --encoding ENC 60 RHOME Print path to R home directory and exit 61 --save Do save workspace at the end of the session 62 --no-save Don't save it 63 --no-environ Don't read the site and user environment files 64 --no-site-file Don't read the site-wide Rprofile 65 --no-init-file Don't read the user R profile 66 --restore Do restore previously saved objects at startup 67 --no-restore-data Don't restore previously saved objects 68 --no-restore-history Don't restore the R history file 69 --no-restore Don't restore anything 70 --vanilla Combine --no-save, --no-restore, --no-site-file, 71 --no-init-file and --no-environ 72 --no-readline Don't use readline for command-line editing 73 --max-ppsize=N Set max size of protect stack to N 74 --min-nsize=N Set min number of fixed size obj's (\"cons cells\") to N 75 --min-vsize=N Set vector heap minimum to N bytes; '4M' = 4 MegaB 76 -q, --quiet Don't print startup message 77 --silent Same as --quiet 78 -s, --no-echo Make R run as quietly as possible 79 --interactive Force an interactive session 80 --verbose Print more information about progress 81 -d, --debugger=NAME Run R through debugger NAME 82 --debugger-args=ARGS Pass ARGS as arguments to the debugger 83 -g TYPE, --gui=TYPE Use TYPE as GUI; possible values are 'X11' (default) 84 and 'Tk'. 85 --arch=NAME Specify a sub-architecture 86 --args Skip the rest of the command line 87 -f FILE, --file=FILE Take input from 'FILE' 88 -e EXPR Execute 'EXPR' and exit 89 90FILE may contain spaces but not shell metacharacters. 91 92Commands: 93 BATCH Run R in batch mode 94 COMPILE Compile files for use with R 95 SHLIB Build shared library for dynamic loading 96 INSTALL Install add-on packages 97 REMOVE Remove add-on packages 98 build Build add-on packages 99 check Check add-on packages 100 LINK Front-end for creating executable programs 101 Rprof Post-process R profiling files 102 Rdconv Convert Rd format to various other formats 103 Rd2pdf Convert Rd format to PDF 104 Rd2txt Convert Rd format to pretty text 105 Stangle Extract S/R code from Sweave documentation 106 Sweave Process Sweave documentation 107 Rdiff Diff R output ignoring headers etc 108 config Obtain configuration information about R 109 javareconf Update the Java configuration variables 110 rtags Create Emacs-style tag files from C, R, and Rd files 111 112Please use 'R CMD command --help' to obtain further information about 113the usage of 'command'. 114 115Options --arch, --no-environ, --no-init-file, --no-site-file and --vanilla 116can be placed between R and CMD, to apply to R processes run by 'command' 117 118Report bugs at <https://bugs.R-project.org>." 119 120## some systems have a more portable sed, e.g. /usr/xpg4/bin/sed on Solaris, 121## so make sure that is used. 122SED=@SED@ 123export SED 124 125error () { 126 echo "ERROR: $*" >&2 127 exit 1 128} 129 130### Argument loop 131args= 132debugger= 133debugger_args= 134gui= 135while test -n "${1}"; do 136 case ${1} in 137 RHOME|--print-home) 138 echo "${R_HOME}"; exit 0 ;; 139 CMD) 140 shift; 141 export R_ARCH 142 . "${R_HOME}/etc${R_ARCH}/ldpaths" 143 exec sh "${R_HOME}/bin/Rcmd" "${@}" ;; 144 -g|--gui) 145 if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then 146 gui="${2}" 147 args="${args} ${1} ${2}" 148 shift 149 else 150 error "option '${1}' requires an argument" 151 fi 152 ;; 153 --gui=*) 154 gui=`echo "${1}" | ${SED} -e 's/[^=]*=//'` 155 args="${args} ${1}" 156 ;; 157 -d|--debugger) 158 if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then 159 debugger="${2}"; shift 160 else 161 error "option '${1}' requires an argument" 162 fi 163 ;; 164 --debugger=*) 165 debugger=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;; 166 --debugger-args=*) 167 debugger_args=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;; 168 -h|--help) 169 echo "${usage}"; exit 0 ;; 170 --args) 171 break ;; 172 --arch) 173 if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then 174 R_ARCH="/${2}" 175 shift 176 else 177 error "option '${1}' requires an argument" 178 fi 179 ## check sub-architecture here for a better error message 180 if ! test -d ${R_HOME}/etc${R_ARCH}; then 181 error "sub-architecture '${1}' is not installed" 182 fi 183 ;; 184 --arch=*) 185 r_arch=`echo "${1}" | ${SED} -e 's/[^=]*=//'` 186 R_ARCH="/${r_arch}" 187 ## check sub-architecture here for a better error message 188 if ! test -d ${R_HOME}/etc${R_ARCH}; then 189 error "sub-architecture '${r_arch}' is not installed" 190 fi 191 ;; 192 -e) 193 if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then 194 a=`(echo "${2}" && echo) | ${SED} -e 's/ /~+~/g' | \ 195 ${SED} -e :a -e N -e '$!ba' -e 's/\n/~n~/g' -e 's/~n~$//g'` 196 shift 197 else 198 error "option '${1}' requires a non-empty argument" 199 fi 200 args="${args} -e $a" 201 ;; 202 -f) 203 if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then 204 a=`echo "${2}" | ${SED} -e 's/ /~+~/g'`; shift 205 else 206 error "option '${1}' requires a filename argument" 207 fi 208 args="${args} -f $a" 209 ;; 210 --file=*) 211 a=`echo "${1}" | ${SED} -e 's/[^=]*=//' | ${SED} -e 's/ /~+~/g'` 212 args="${args} --file=$a" 213 ;; 214 --no-environ) 215 R_ENVIRON='' 216 export R_ENVIRON 217 R_ENVIRON_USER='' 218 export R_ENVIRON_USER 219 args="${args} ${1}" 220 ;; 221 --no-site-file) 222 R_PROFILE='' 223 export R_PROFILE 224 args="${args} ${1}" 225 ;; 226 --no-init-file) 227 R_PROFILE_USER='' 228 export R_PROFILE_USER 229 args="${args} ${1}" 230 ;; 231 --vanilla) 232 R_ENVIRON='' 233 export R_ENVIRON 234 R_ENVIRON_USER='' 235 export R_ENVIRON_USER 236 R_PROFILE='' 237 export R_PROFILE 238 R_PROFILE_USER='' 239 export R_PROFILE_USER 240 args="${args} ${1}" 241 ;; 242 *) 243 args="${args} ${1}" ;; 244 esac 245 shift 246done 247 248. "${R_HOME}/etc${R_ARCH}/ldpaths" 249 250R_binary="${R_HOME}/bin/exec${R_ARCH}/R" 251export R_ARCH 252 253case "${gui}" in 254Tk|tk|X11|x11) 255 ;; 256"") 257 ;; 258*) 259 error "unknown GUI ${gui}" 260esac 261 262## R_HOME may have moved, so check 263if test -x "${R_HOME}"; then 264 : 265else 266 error "R_HOME ('${R_HOME}') not found" 267fi 268 269## Startup 270if test -z "${debugger}"; then 271 exec "${R_binary}" @R_BATCHSAVE@ ${args} "${@}" 272else 273 ## Ideally, we would like the debugger to start R with additional 274 ## ('inferior') arguments, but not all debuggers can do this. We know 275 ## about valgrind and some versions of GDB , and deal with these. 276 ## Otherwise, to be on the safe side, we disregard non-debugger 277 ## command line args. 278 args_ok=no 279 case "`${debugger} --version 2>/dev/null`" in 280 "GNU gdb"*) 281 if ${debugger} --help 2>/dev/null | \ 282 grep ' *--args' >/dev/null; then 283 args_ok=yes 284 debugger_args="${debugger_args} --args" 285 fi 286 ;; 287 valgrind*) 288 args_ok=yes 289 ;; 290 esac 291 if test -n "${args}${*}" && test "${args_ok}" = no; then 292 args=`expr "${args} ${*}" : " *\(.*\)"` 293 echo "*** Further command line arguments ('${args}') disregarded" 294 echo "*** (maybe use 'run ${args}' from *inside* ${debugger})" 295 echo "" 296 exec ${debugger} ${debugger_args} "${R_binary}" 297 else 298 exec ${debugger} ${debugger_args} "${R_binary}" ${args} "${@}" 299 fi 300fi 301 302### Local Variables: *** 303### mode: sh *** 304### sh-indentation: 2 *** 305### End: *** 306