The R Project SVN R

Rev

Rev 84466 | Details | Compare with Previous | Last modification | View Log | RSS feed

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