[Rd] R-2.5.0 and unlink/wildcards

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 25 14:01:09 CEST 2007


On Wed, 25 Apr 2007, Peter Dalgaard wrote:

> Ernest Turro wrote:
>> It seems unlink doesn't work with wildcards in 2.5.0. I've tried
>> R-2.5.0 under gnu/linux from source and the Mac binary from att
>> research. Example:
>>
>> > dir()
>> [1] "bgx.Rnw" "bgx.pdf" "run.1"
>> > unlink("run.*",recursive=T)
>> > dir()
>> [1] "bgx.Rnw" "bgx.pdf" "run.1"
>> > unlink("run.1",recursive=T)
>> > dir()
>> [1] "bgx.Rnw" "bgx.pdf"
>>
>>
> Yes. The argument is now passed through shQuote, and that has the side
> effect of removing wildcard expansions. If this was intentional, someone
> forgot to change the help page...
>
> Presumably, the change was done to prevent issues with embedded spaces:

NEWS says:

     o	unlink() on Unix-alikes failed for paths containing spaces.

> unlink("Program Files") would otherwise delete "Program" and "Files". It
> is not obvious to me how this can be achieved  while retaining wildcard
> expansion.

By using Sys.glob(), but it never got done and no one using pre-2.5.0 
reported this so presumably few people use it.  I'll put a fix in 2.5.0 
patched shortly.

There is the following comment in the R source file

##--- The following should/could really be done in C [platform !] :
unlink <- function(x, recursive = FALSE) {

and that would be a better idea (the Windows version is in C).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list