> Why is commandArgs()[1] = "/usr/lib64/R/bin/exec/R" and not
> "getopt_test.R" as described by the help (?getopt)?

That used to work but R changed the behavior of the commandArgs()
function a couple of years ago, I guess the orginal author of getopt
didn't update his example then.

This will do the trick:

args <- commandArgs()
file_index <- grepl("--file=", args)
self <- gsub("--file=", "", args[file_index])

> This behaviour I don't like at all. Why getopt does not distinguish
> beetween options starting with alt least one hyphen and normal arguments
> starting without hyphen? How it is possible to handle such a situation?
> Have I myself to split the arguments into two lists, one with hyphen and
> one without hyphen, and then pass only this list with hyphen to getopt?
> Or is there a better solution?

The author of getopt started but did not finish adding positional
arguments to ``getopt``.  Howevor, positional arguments have been
supported in the ``optparse`` package for over a year if you specify
``positional_args=TRUE`` to the ``parse_args`` function.

- Trevor Davis

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to