~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/rkward.sh.template

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2008-04-20 21:30:00 UTC
  • mfrom: (1.2.2 upstream) (3.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080420213000-fs4i8efmfc793bnn
new upstream release
closes: #475175
closes: #463348
closes: #475982

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
# Shell wrapper for rkward executable.
3
3
 
 
4
## make sure, we always run in a tty. Otherwise R would go into non-interactive mode and behaves strangely.
 
5
## this can be removed later. For R versions 2.3.0 and greater, we set R_Interactive from C
 
6
if tty -s; then
 
7
  :
 
8
else
 
9
  # not on a tty? Try to invoke a suitable xterm
 
10
  if [ -z $RKWARD_NORECURSE ]; then
 
11
    for xtrm in konsole x-terminal-emulator xterm
 
12
    do
 
13
      xtrmc=`which $xtrm`
 
14
      if [ ! -z $xtrmc -a -x $xtrmc ]; then
 
15
        RKWARD_NORECURSE=y $xtrmc -e $0 "$@"
 
16
        exit
 
17
      fi
 
18
    done
 
19
  fi
 
20
fi
 
21
 
4
22
R_HOME_DIR=###R_HOME_DIR###
5
 
R_binary="$R_HOME_DIR/bin/R"
 
23
export R_binary="$R_HOME_DIR/bin/R"
6
24
 
7
25
## Location of R may have moved, so check
8
26
if test -x "${R_binary}"; then
11
29
  error "R binary ('${R_binary}') not found. Most likely your installation of R has moved to a new location. Please rebuild rkward."
12
30
fi
13
31
 
14
 
## Apparently on some systems an embedded R gets outsmarted somehow, and LC_NUMERIC is set to some dangerous value for the whole app (likely via some Qt stuff)
 
32
## Apparently on some systems an embedded R gets outsmarted somehow, and LC_NUMERIC is set to some dangerous value for the whole app (via SCIM)
15
33
## To prevent this, set it here, explicitely. R does not work with wrong settings of LC_NUMERIC.
 
34
 
 
35
## First, however, need to unset LC_ALL, if set. Instead we set LANG, so the default will be the same, where not overridden
 
36
if [ -z "$LC_ALL" ]; then
 
37
  :
 
38
else
 
39
  export LANG="$LC_ALL"
 
40
  unset LC_ALL
 
41
  echo "Warning: unsetting LC_ALL"
 
42
fi
 
43
 
 
44
# handle --debugger argument (if any)
 
45
# the loop partially copied from the R wrapper script
 
46
error () {
 
47
  echo "ERROR: $*" >&2
 
48
  exit 1
 
49
}
 
50
 
 
51
debugger=
 
52
args=
 
53
while test -n "${1}"; do
 
54
  case ${1} in
 
55
    --debugger)
 
56
      if test -n "`echo ${2} | sed 's/^-.*//'`"; then
 
57
        debugger="${2}"; shift
 
58
      else
 
59
        error "option '${1}' requires an argument"
 
60
      fi
 
61
      ;;
 
62
    *)
 
63
      args="${args} ${1}" ;;
 
64
  esac
 
65
  shift
 
66
done
 
67
 
 
68
## set LC_NUMERIC to "C"
16
69
export LC_NUMERIC="C"
17
70
 
18
71
## Start rkward. Running through R CMD to set all the relevant R enviroment variables
19
 
exec $R_binary CMD $0.bin "$@"
 
72
exec $R_binary CMD $debugger $0.bin ${args}