Making R CMD nicer

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Making R CMD nicer

Jason Xu
Hello everyone,

First time posting in the R mailing lists so hopefully this works well.
I noticed when I type `R CMD` I get this unhelpful message:

/usr/lib/R/bin/Rcmd: 60: shift: can't shift that many

This probably comes from the file Rcmd.in. This should be easily fixed by
checking $#.

I also think it would be nice if `R CMD help` showed the usable commands.
In fact I think the CMD syntax is unnecessary since the man page shows
using R with an infile or outfile must use redirection, so the syntax can
be simply "R install" (like in git).

Thanks,
Jason

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making R CMD nicer

Abby Spurdle
> First time posting in the R mailing lists so hopefully this works well.
> I noticed when I type `R CMD` I get this unhelpful message:
> /usr/lib/R/bin/Rcmd: 60: shift: can't shift that many

I wasn't able to reproduce this.
Maybe it's a Linux thing.
But then, I suspect you've omitted some of your input.

> I also think it would be nice if `R CMD help` showed the usable commands.

What do you mean...
All of the following give you the "usable commands":

> R CMD
> R CMD -h
> R CMD --help

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making R CMD nicer

Gábor Csárdi
For the record, this is Linux R-devel:

root@4bef68c16864:~# R CMD
/opt/R-devel/lib/R/bin/Rcmd: 60: shift: can't shift that many
root@4bef68c16864:~# R CMD -h
/opt/R-devel/lib/R/bin/Rcmd: 62: exec: -h: not found
root@4bef68c16864:~# R CMD --help
/opt/R-devel/lib/R/bin/Rcmd: 62: exec: --help: not found

This is R-release on macOS:

❯ R CMD
/Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62:
/Library/Frameworks/R.framework/Resources/bin/: is a directory
/Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec:
/Library/Frameworks/R.framework/Resources/bin/: cannot execute:
Undefined error: 0
❯ R CMD -h
/Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: -h:
invalid option
exec: usage: exec [-cl] [-a name] file [redirection ...]
❯ R CMD --help
/Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: --:
invalid option
exec: usage: exec [-cl] [-a name] file [redirection ...]

On Windows you indeed get a useful list of commands and more helpful tips.

Gabor


On Sun, Jun 30, 2019 at 11:36 PM Abby Spurdle <[hidden email]> wrote:

>
> > First time posting in the R mailing lists so hopefully this works well.
> > I noticed when I type `R CMD` I get this unhelpful message:
> > /usr/lib/R/bin/Rcmd: 60: shift: can't shift that many
>
> I wasn't able to reproduce this.
> Maybe it's a Linux thing.
> But then, I suspect you've omitted some of your input.
>
> > I also think it would be nice if `R CMD help` showed the usable commands.
>
> What do you mean...
> All of the following give you the "usable commands":
>
> > R CMD
> > R CMD -h
> > R CMD --help
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making R CMD nicer

Abby Spurdle
In that case, I was wrong.
And I must apologize...

In saying that, good to see Windows out performing Linux on the command
line...


On Mon, Jul 1, 2019 at 11:30 AM Gábor Csárdi <[hidden email]> wrote:

>
> For the record, this is Linux R-devel:
>
> root@4bef68c16864:~# R CMD
> /opt/R-devel/lib/R/bin/Rcmd: 60: shift: can't shift that many
> root@4bef68c16864:~# R CMD -h
> /opt/R-devel/lib/R/bin/Rcmd: 62: exec: -h: not found
> root@4bef68c16864:~# R CMD --help
> /opt/R-devel/lib/R/bin/Rcmd: 62: exec: --help: not found
>
> This is R-release on macOS:
>
> ❯ R CMD
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62:
> /Library/Frameworks/R.framework/Resources/bin/: is a directory
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec:
> /Library/Frameworks/R.framework/Resources/bin/: cannot execute:
> Undefined error: 0
> ❯ R CMD -h
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: -h:
> invalid option
> exec: usage: exec [-cl] [-a name] file [redirection ...]
> ❯ R CMD --help
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: --:
> invalid option
> exec: usage: exec [-cl] [-a name] file [redirection ...]
>
> On Windows you indeed get a useful list of commands and more helpful tips.
>
> Gabor
>
>
> On Sun, Jun 30, 2019 at 11:36 PM Abby Spurdle <[hidden email]> wrote:
> >
> > > First time posting in the R mailing lists so hopefully this works
well.
> > > I noticed when I type `R CMD` I get this unhelpful message:
> > > /usr/lib/R/bin/Rcmd: 60: shift: can't shift that many
> >
> > I wasn't able to reproduce this.
> > Maybe it's a Linux thing.
> > But then, I suspect you've omitted some of your input.
> >
> > > I also think it would be nice if `R CMD help` showed the usable
commands.

> >
> > What do you mean...
> > All of the following give you the "usable commands":
> >
> > > R CMD
> > > R CMD -h
> > > R CMD --help
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making R CMD nicer

Jason Xu
In reply to this post by Gábor Csárdi
Yes I'm using R 3.4.4 on Ubuntu 18.04. I doubt the Windows version would
make use of a bash script.
I'm all for a more consistent interface. It puzzles me that a shell script
is used at all since that does not seem portable, especially for Windows
users.

To my surprise I discovered the R that's called from shell, usr/bin/R, is
actually just a shell script. The binary that's called seems to be
/usr/lib/R/bin/exec/R which is a tiny executable that then probably calls
something else.
In comparison the python called from shell, /usr/bin/python3.6, really is a
binary. I'm sure there's a good reason that R uses a shell wrapper script
but it's not like a C program can't parse arguments or set env vars.





On Sun, Jun 30, 2019 at 7:30 PM Gábor Csárdi <[hidden email]> wrote:

> For the record, this is Linux R-devel:
>
> root@4bef68c16864:~# R CMD
> /opt/R-devel/lib/R/bin/Rcmd: 60: shift: can't shift that many
> root@4bef68c16864:~# R CMD -h
> /opt/R-devel/lib/R/bin/Rcmd: 62: exec: -h: not found
> root@4bef68c16864:~# R CMD --help
> /opt/R-devel/lib/R/bin/Rcmd: 62: exec: --help: not found
>
> This is R-release on macOS:
>
> ❯ R CMD
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62:
> /Library/Frameworks/R.framework/Resources/bin/: is a directory
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec:
> /Library/Frameworks/R.framework/Resources/bin/: cannot execute:
> Undefined error: 0
> ❯ R CMD -h
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: -h:
> invalid option
> exec: usage: exec [-cl] [-a name] file [redirection ...]
> ❯ R CMD --help
> /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: --:
> invalid option
> exec: usage: exec [-cl] [-a name] file [redirection ...]
>
> On Windows you indeed get a useful list of commands and more helpful tips.
>
> Gabor
>
>
> On Sun, Jun 30, 2019 at 11:36 PM Abby Spurdle <[hidden email]> wrote:
> >
> > > First time posting in the R mailing lists so hopefully this works well.
> > > I noticed when I type `R CMD` I get this unhelpful message:
> > > /usr/lib/R/bin/Rcmd: 60: shift: can't shift that many
> >
> > I wasn't able to reproduce this.
> > Maybe it's a Linux thing.
> > But then, I suspect you've omitted some of your input.
> >
> > > I also think it would be nice if `R CMD help` showed the usable
> commands.
> >
> > What do you mean...
> > All of the following give you the "usable commands":
> >
> > > R CMD
> > > R CMD -h
> > > R CMD --help
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making R CMD nicer

Duncan Murdoch-2
In reply to this post by Abby Spurdle
On 30/06/2019 8:08 p.m., Abby Spurdle wrote:
> In that case, I was wrong.
> And I must apologize...
>
> In saying that, good to see Windows out performing Linux on the command
> line...

That's going to set the bees abuzz...

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making R CMD nicer

Jason Xu
In reply to this post by Abby Spurdle
In my humble personal opinion, I try to avoid bash scripts longer than a
couple lines because I find the syntax so obtuse and unintuitive it's
difficult to maintain and write less buggy code. But that is mostly a
reflection of my personal inexperience.
I think the only time a bash script is really needed is for maximum
portability in systems _with bash_.
(I would use python for a wrapper in personal projects, given python comes
pre-installed on many linux systems and OS X, but I completely understand
not wanting to burden Windows users with an extra python dependency to
install.)





On Sun, Jun 30, 2019 at 8:08 PM Abby Spurdle <[hidden email]> wrote:

> In that case, I was wrong.
> And I must apologize...
>
> In saying that, good to see Windows out performing Linux on the command
> line...
>
>
> On Mon, Jul 1, 2019 at 11:30 AM Gábor Csárdi <[hidden email]>
> wrote:
> >
> > For the record, this is Linux R-devel:
> >
> > root@4bef68c16864:~# R CMD
> > /opt/R-devel/lib/R/bin/Rcmd: 60: shift: can't shift that many
> > root@4bef68c16864:~# R CMD -h
> > /opt/R-devel/lib/R/bin/Rcmd: 62: exec: -h: not found
> > root@4bef68c16864:~# R CMD --help
> > /opt/R-devel/lib/R/bin/Rcmd: 62: exec: --help: not found
> >
> > This is R-release on macOS:
> >
> > ❯ R CMD
> > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62:
> > /Library/Frameworks/R.framework/Resources/bin/: is a directory
> > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec:
> > /Library/Frameworks/R.framework/Resources/bin/: cannot execute:
> > Undefined error: 0
> > ❯ R CMD -h
> > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: -h:
> > invalid option
> > exec: usage: exec [-cl] [-a name] file [redirection ...]
> > ❯ R CMD --help
> > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: --:
> > invalid option
> > exec: usage: exec [-cl] [-a name] file [redirection ...]
> >
> > On Windows you indeed get a useful list of commands and more helpful
> tips.
> >
> > Gabor
> >
> >
> > On Sun, Jun 30, 2019 at 11:36 PM Abby Spurdle <[hidden email]>
> wrote:
> > >
> > > > First time posting in the R mailing lists so hopefully this works
> well.
> > > > I noticed when I type `R CMD` I get this unhelpful message:
> > > > /usr/lib/R/bin/Rcmd: 60: shift: can't shift that many
> > >
> > > I wasn't able to reproduce this.
> > > Maybe it's a Linux thing.
> > > But then, I suspect you've omitted some of your input.
> > >
> > > > I also think it would be nice if `R CMD help` showed the usable
> commands.
> > >
> > > What do you mean...
> > > All of the following give you the "usable commands":
> > >
> > > > R CMD
> > > > R CMD -h
> > > > R CMD --help
> > >
> > >         [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making R CMD nicer

barry rowlingson
In reply to this post by Abby Spurdle
If you write a lot of R code to run as command line scripts then look at
Dirk E's "littler":

$ r --help

Usage: r [options] [-|file]

Launch GNU R to execute the R commands supplied in the specified file, or
from stdin if '-' is used. Suitable for so-called shebang '#!/'-line
scripts.

Options:
  -h, --help           Give this help list
      --usage          Give a short usage message
  -V, --version        Show the version number
  -v, --vanilla        Pass the '--vanilla' option to R
  -t, --rtemp          Use per-session temporary directory as R does
  -i, --interactive    Let interactive() return 'true' rather than 'false'
  -q, --quick          Skip autoload / delayed assign of default libraries
  -p, --verbose        Print the value of expressions to the console
  -l, --packages list  Load the R packages from the comma-separated 'list'
  -d, --datastdin      Prepend command to load 'X' as csv from stdin
  -L, --libpath dir    Add directory to library path via '.libPaths(dir)'
  -e, --eval expr      Let R evaluate 'expr'

available from an archive near you...


On Mon, Jul 1, 2019 at 8:58 AM Jason Xu <[hidden email]> wrote:

> In my humble personal opinion, I try to avoid bash scripts longer than a
> couple lines because I find the syntax so obtuse and unintuitive it's
> difficult to maintain and write less buggy code. But that is mostly a
> reflection of my personal inexperience.
> I think the only time a bash script is really needed is for maximum
> portability in systems _with bash_.
> (I would use python for a wrapper in personal projects, given python comes
> pre-installed on many linux systems and OS X, but I completely understand
> not wanting to burden Windows users with an extra python dependency to
> install.)
>
>
>
>
>
> On Sun, Jun 30, 2019 at 8:08 PM Abby Spurdle <[hidden email]> wrote:
>
> > In that case, I was wrong.
> > And I must apologize...
> >
> > In saying that, good to see Windows out performing Linux on the command
> > line...
> >
> >
> > On Mon, Jul 1, 2019 at 11:30 AM Gábor Csárdi <[hidden email]>
> > wrote:
> > >
> > > For the record, this is Linux R-devel:
> > >
> > > root@4bef68c16864:~# R CMD
> > > /opt/R-devel/lib/R/bin/Rcmd: 60: shift: can't shift that many
> > > root@4bef68c16864:~# R CMD -h
> > > /opt/R-devel/lib/R/bin/Rcmd: 62: exec: -h: not found
> > > root@4bef68c16864:~# R CMD --help
> > > /opt/R-devel/lib/R/bin/Rcmd: 62: exec: --help: not found
> > >
> > > This is R-release on macOS:
> > >
> > > ❯ R CMD
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62:
> > > /Library/Frameworks/R.framework/Resources/bin/: is a directory
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec:
> > > /Library/Frameworks/R.framework/Resources/bin/: cannot execute:
> > > Undefined error: 0
> > > ❯ R CMD -h
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: -h:
> > > invalid option
> > > exec: usage: exec [-cl] [-a name] file [redirection ...]
> > > ❯ R CMD --help
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: --:
> > > invalid option
> > > exec: usage: exec [-cl] [-a name] file [redirection ...]
> > >
> > > On Windows you indeed get a useful list of commands and more helpful
> > tips.
> > >
> > > Gabor
> > >
> > >
> > > On Sun, Jun 30, 2019 at 11:36 PM Abby Spurdle <[hidden email]>
> > wrote:
> > > >
> > > > > First time posting in the R mailing lists so hopefully this works
> > well.
> > > > > I noticed when I type `R CMD` I get this unhelpful message:
> > > > > /usr/lib/R/bin/Rcmd: 60: shift: can't shift that many
> > > >
> > > > I wasn't able to reproduce this.
> > > > Maybe it's a Linux thing.
> > > > But then, I suspect you've omitted some of your input.
> > > >
> > > > > I also think it would be nice if `R CMD help` showed the usable
> > commands.
> > > >
> > > > What do you mean...
> > > > All of the following give you the "usable commands":
> > > >
> > > > > R CMD
> > > > > R CMD -h
> > > > > R CMD --help
> > > >
> > > >         [[alternative HTML version deleted]]
> > > >
> > > > ______________________________________________
> > > > [hidden email] mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel