The R Project SVN R

Rev

Rev 58676 | Rev 67533 | Go to most recent revision | 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
 
12256 pd 4
R_HOME_DIR=
44146 plummer 5
if 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"
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
52418 ripley 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
27067 ripley 73
  --max-ppsize=N        Set max size of protect stack to N
7350 hornik 74
  -q, --quiet           Don't print startup message
75
  --silent              Same as --quiet
76
  --slave               Make R run as quietly as possible
44121 ripley 77
  --interactive         Force an interactive session
7350 hornik 78
  --verbose             Print more information about progress
8450 hornik 79
  -d, --debugger=NAME   Run R through debugger NAME
21742 hornik 80
  --debugger-args=ARGS  Pass ARGS as arguments to the debugger
55931 ripley 81
  -g TYPE, --gui=TYPE	Use TYPE as GUI; possible values are 'X11' (default)
82
			and 'Tk'.
37300 ripley 83
  --arch=NAME		Specify a sub-architecture
26121 ripley 84
  --args                Skip the rest of the command line
55931 ripley 85
  -f FILE, --file=FILE  Take input from 'FILE'
50909 falcon 86
  -e EXPR               Execute 'EXPR' and exit
2510 maechler 87
 
60191 hornik 88
FILE may contain spaces but not shell metacharacters.
55927 ripley 89
 
2510 maechler 90
Commands:
7605 hornik 91
  BATCH			Run R in batch mode
7350 hornik 92
  COMPILE		Compile files for use with R
7605 hornik 93
  SHLIB			Build shared library for dynamic loading
7350 hornik 94
  INSTALL		Install add-on packages
95
  REMOVE		Remove add-on packages
7605 hornik 96
  build			Build add-on packages
97
  check			Check add-on packages
11551 hornik 98
  LINK			Front-end for creating executable programs
99
  Rprof			Post-process R profiling files
7350 hornik 100
  Rdconv		Convert Rd format to various other formats
49400 ripley 101
  Rd2pdf		Convert Rd format to PDF
102
  Rd2txt		Convert Rd format to pretty text
39174 hornik 103
  Stangle		Extract S/R code from Sweave documentation
104
  Sweave		Process Sweave documentation
46798 ripley 105
  Rdiff			Diff R output ignoring headers etc
106
  config		Obtain configuration information about R
107
  javareconf		Update the Java configuration variables
47275 deepayan 108
  rtags                 Create Emacs-style tag files from C, R, and Rd files
2510 maechler 109
 
20002 hornik 110
Please use 'R CMD command --help' to obtain further information about
111
the usage of 'command'.
7605 hornik 112
 
54680 ripley 113
Options --arch, --no-environ, --no-init-file, --no-site-file and --vanilla
114
can be placed between R and CMD, to apply to R processes run by 'command'
54660 ripley 115
 
58676 ripley 116
Report bugs at bugs.r-project.org "
7350 hornik 117
 
43236 ripley 118
## some systems have a more portable sed, e.g. /usr/xpg4/bin/sed on Solaris,
119
## so make sure that is used.
120
SED=@SED@
121
export SED
122
 
27363 ripley 123
error () {
27353 hornik 124
  echo "ERROR: $*" >&2
125
  exit 1
126
}
127
 
10093 hornik 128
### Argument loop
7350 hornik 129
args=
130
debugger=
21742 hornik 131
debugger_args=
31488 ripley 132
gui=
7220 hornik 133
while test -n "${1}"; do
134
  case ${1} in
8140 hornik 135
    RHOME|--print-home)
11481 hornik 136
      echo "${R_HOME}"; exit 0 ;;
7220 hornik 137
    CMD)
11481 hornik 138
      shift;
37300 ripley 139
      export R_ARCH
55087 ripley 140
      . "${R_HOME}/etc${R_ARCH}/ldpaths"
39954 ripley 141
      exec sh "${R_HOME}/bin/Rcmd" @OSF_SH_BUG@ ;;
31488 ripley 142
    -g|--gui)
43236 ripley 143
      if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then      
31488 ripley 144
	gui="${2}"
145
        args="${args} ${1} ${2}"
146
	shift
147
      else
148
	error "option '${1}' requires an argument"
149
      fi
7689 hornik 150
      ;;
31488 ripley 151
    --gui=*)
43236 ripley 152
      gui=`echo "${1}" | ${SED} -e 's/[^=]*=//'`
31488 ripley 153
      args="${args} ${1}"
154
      ;;
8082 pd 155
    -d|--debugger)
43236 ripley 156
      if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then      
8140 hornik 157
	debugger="${2}"; shift
158
      else
27353 hornik 159
	error "option '${1}' requires an argument"
8140 hornik 160
      fi
161
      ;;
7350 hornik 162
    --debugger=*)
43236 ripley 163
      debugger=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;;
21742 hornik 164
    --debugger-args=*)
43236 ripley 165
      debugger_args=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;;
7350 hornik 166
    -h|--help)
7444 hornik 167
      echo "${usage}"; exit 0 ;;
35773 ripley 168
    --args)
35837 hornik 169
      break ;;
41398 ripley 170
    --arch)
43236 ripley 171
      if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then
37327 ripley 172
	R_ARCH="/${2}"
37300 ripley 173
        shift
174
      else
175
        error "option '${1}' requires an argument"
176
      fi
51664 ripley 177
      ## check sub-architecture here for a better error message
178
      if ! test -d ${R_HOME}/etc${R_ARCH}; then
179
        error "sub-architecture '${1}' is not installed"
180
      fi
37300 ripley 181
      ;;
182
    --arch=*)
43236 ripley 183
      r_arch=`echo "${1}" | ${SED} -e 's/[^=]*=//'`
37300 ripley 184
      R_ARCH="/${r_arch}"
51664 ripley 185
      ## check sub-architecture here for a better error message
186
      if ! test -d ${R_HOME}/etc${R_ARCH}; then
187
        error "sub-architecture '${r_arch}' is not installed"
188
      fi
37300 ripley 189
      ;;
41398 ripley 190
    -e)
43236 ripley 191
      if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then      
192
	a=`echo "${2}" | ${SED} -e 's/ /~+~/g'`; shift
41398 ripley 193
      else
194
	error "option '${1}' requires an argument"
195
      fi
196
      args="${args} -e $a"
197
      ;;
55931 ripley 198
    -f)
199
      if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then      
200
	a=`echo "${2}" | ${SED} -e 's/ /~+~/g'`; shift
201
      else
202
	error "option '${1}' requires an argument"
203
      fi
204
      args="${args} -f $a"
205
      ;;
206
    --file=*)
207
      a=`echo "${1}" | ${SED} -e 's/[^=]*=//' | ${SED} -e 's/ /~+~/g'`
208
      args="${args} --file=$a"
209
      ;;
54659 ripley 210
    --no-environ)
211
      export R_ENVIRON=''
212
      export R_ENVIRON_USER=''
213
      args="${args} ${1}"
214
      ;;
215
    --no-site-file)
216
      export R_PROFILE=''
217
      args="${args} ${1}"
218
      ;;
219
    --no-init-file)
220
      export R_PROFILE_USER=''
221
      args="${args} ${1}"
222
      ;;
223
    --vanilla)
224
      export R_ENVIRON=''
225
      export R_ENVIRON_USER=''
226
      export R_PROFILE=''
227
      export R_PROFILE_USER=''
228
      args="${args} ${1}"
229
      ;;
4562 pd 230
    *)
35837 hornik 231
      args="${args} ${1}" ;;
4562 pd 232
  esac
233
  shift
234
done
2159 hornik 235
 
55087 ripley 236
. "${R_HOME}/etc${R_ARCH}/ldpaths"
37328 ripley 237
 
37327 ripley 238
R_binary="${R_HOME}/bin/exec${R_ARCH}/R"
239
export R_ARCH
37300 ripley 240
 
33411 ripley 241
case "${gui}" in
35624 ripley 242
Tk|tk|X11|x11)
33411 ripley 243
  ;;
244
"")
245
  ;;
246
*)
247
  error "unknown GUI ${gui}"
248
esac
31488 ripley 249
 
11481 hornik 250
## R_HOME may have moved, so check
21742 hornik 251
if test -x "${R_HOME}"; then
12256 pd 252
  :
253
else
27353 hornik 254
  error "R_HOME ('${R_HOME}') not found"
8082 pd 255
fi
256
 
11481 hornik 257
## Startup
7350 hornik 258
if test -z "${debugger}"; then
39954 ripley 259
  exec "${R_binary}" @R_BATCHSAVE@ ${args} @OSF_SH_BUG@
5471 hornik 260
else
21742 hornik 261
  ## Ideally, we would like the debugger to start R with additional
262
  ## ('inferior') arguments, but not all debuggers can do this.  We know
21931 hornik 263
  ## about valgrind and some versions of GDB , and deal with these.
264
  ## Otherwise, to be on the safe side, we disregard non-debugger
265
  ## command line args.
266
  args_ok=no
21742 hornik 267
  case "`${debugger} --version 2>/dev/null`" in
268
    "GNU gdb"*)
21931 hornik 269
      if ${debugger} --help 2>/dev/null | \
23186 hornik 270
          grep ' *--args' >/dev/null; then
21931 hornik 271
	args_ok=yes
272
	debugger_args="${debugger_args} --args"
21742 hornik 273
      fi
274
      ;;
21931 hornik 275
    valgrind*)
276
      args_ok=yes
277
      ;;
21742 hornik 278
  esac
35837 hornik 279
  if test -n "${args}${*}" && test "${args_ok}" = no; then
35839 hornik 280
    args=`expr "${args} ${*}" : " *\(.*\)"`
281
    echo "*** Further command line arguments ('${args}') disregarded"
282
    echo "*** (maybe use 'run ${args}' from *inside* ${debugger})"
21931 hornik 283
    echo ""
35837 hornik 284
    exec ${debugger} ${debugger_args} "${R_binary}"
21931 hornik 285
  else
39954 ripley 286
    exec ${debugger} ${debugger_args} "${R_binary}" ${args} @OSF_SH_BUG@
21931 hornik 287
  fi
5471 hornik 288
fi
289
 
4562 pd 290
### Local Variables: ***
291
### mode: sh ***
292
### sh-indentation: 2 ***
293
### End: ***