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