Skip to content
Prev 45304 / 63421 Next

Why cannot `Rscript -e` accept an empty line?

On Sat, Mar 9, 2013 at 9:32 PM, Yihui Xie <xie at yihui.name> wrote:
There's some over-zealous argument parsing in the main R startup
shell script. You didn't try negative numbers, did you?

$ Rscript  -e "-1"
ERROR: option '-e' requires an argument
$ Rscript  -e "+1"
[1] 1

The R script strips anything starting with a - from the arg after -e
and throws that error if there's nothing left. The relevant lines are:

    -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

- now at least that's on Unix. The Windows problem looks like its
doing something else, and mashing some quotes up and passing 'e' as an
expression to one of the other -e options.

 Not sure what the fix might be, except maybe for the user to always
wrap their expressions in curly brackets...

Barry
Message-ID: <CANVKczNe5=qbGpD6cDF5N1NetzWNYe=M7FrdgF=0G=V80dBRsg@mail.gmail.com>
In-Reply-To: <a5ece76a00fe4140a55e967d550d9100@EX-0-HT0.lancs.local>