On 5 January 2008 at 19:34, Dan Davison wrote:
| I think there's a minor bug in the argument-processing carried out by Rscript.
| The effect is that if one passes "-g" as a flag to the script, it is 
erroneously 
| exposed to the main executable's argument processing and therefore generates 
a 
| message about not being able to comply with the request for a particular GUI. 
| Uppercase G is fine as are the other 25 letters in upper or lower case.
| 
| I noticed this with R-2.5.1 and carried out the tests below with 
R-devel-2.7.0.
[...]
| ~/src/scripts/R> /usr/src/R/R-devel/bin/Rscript -e "commandArgs()" -a -b -f 
-g -h
| WARNING: unknown gui '-h', using X11
| 
|  [1] "/usr/src/R/R-devel/bin/exec/R" "--slave"                      
|  [3] "--no-restore"                  "-e"                           
|  [5] "commandArgs()"                 "--args"                       
|  [7] "-a"                            "-b"                           
|  [9] "-f"                            "-g"                           
| [11] "-h"                           

For what it's worth, littler does not have that problem with   Following GNU
traditions, we stick all arguments that are not referring to existing
switches into the argv vector which you can access normally:

        [EMAIL PROTECTED]:~> r -e 'print(argv)' -- -a -b -f -g -h -i -j
        [1] "-a" "-b" "-f" "-g" "-h" "-i" "-j"

It is then up to you to parse these remaining arguments. If you hit an
existing option like -h _before_ the --, its code gets invoked.  This also
works when code is piped into littler (when '-' is used to turn on stdin
parsing):

        [EMAIL PROTECTED]:~> echo 'print(argv)' | r - -- -a -b -f -g -h -i -j
        [1] "-a" "-b" "-f" "-g" "-h" "-i" "-j"

Prior versions had an off-by-one error in the way argv was built, but version
0.1.0 which I just put onto

        http://dirk.eddelbuettel.com/code/littler.html

should be fine.

Hope this helps,  Dirk

-- 
Three out of two people have difficulties with fractions.

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to