Bug 15170 - list.dirs returns full paths even with full.names=FALSE
list.dirs returns full paths even with full.names=FALSE
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: I/O
R 2.15.2
Other Linux
: P5 enhancement
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-14 20:26 UTC by Sam Steingold
Modified: 2013-08-27 19:13 UTC (History)
2 users (show)

See Also:


Attachments
Patch to the documentation explicitly indicating that full.names is ignored by list.dirs (770 bytes, patch)
2013-08-20 19:58 UTC, Gabriel Becker
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Steingold 2013-01-14 20:26:12 UTC
list.dirs returns full paths even with full.names=FALSE:

> list.dirs("/etc",recursive=FALSE,full.names=FALSE)
  [1] "/etc/.java"                 "/etc/ConsoleKit"           
  [3] "/etc/ImageMagick"           "/etc/NetworkManager"       
  [5] "/etc/ODBCDataSources"       "/etc/R"                    
  [7] "/etc/UPower"                "/etc/X11"                  
  [9] "/etc/acpi"                  "/etc/alternatives"         
 [11] "/etc/anthy"                 "/etc/apache2"              

I expected something like

".java" "ConsoleKit" ...
Comment 1 Gabriel Becker 2013-08-20 18:35:17 UTC
I have a sneaking suspicion this will fall into the "it doesn't work as intended/described in the documentation but cannot be changed because it has worked this way forever and code may rely on it" category.

I am willing and able to prepare a patch for this if there is interest from R-core in such a change, but I will hold off on putting any real effort into it until I hear something to that effect.
Comment 2 Sam Steingold 2013-08-20 19:04:31 UTC
(In reply to comment #1)
> I have a sneaking suspicion this will fall into the "it doesn't work as
> intended/described in the documentation but cannot be changed because it has
> worked this way forever and code may rely on it" category.

In that case the documentation must be fixed.

Also, a functional fix can be done along these lines

1. deprecate `full.names` argument

2. add `full.path` argument which actually does what `full.names` was supposed to do
Comment 3 Gabriel Becker 2013-08-20 19:58:02 UTC
Created attachment 1477 [details]
Patch to the documentation explicitly indicating that full.names is ignored by list.dirs

(In reply to comment #2)
> (In reply to comment #1)
> > I have a sneaking suspicion this will fall into the "it doesn't work as
> > intended/described in the documentation but cannot be changed because it has
> > worked this way forever and code may rely on it" category.
> 
> In that case the documentation must be fixed.

I agree and have attached a documentation patch to this effect.

I am more in favor of changing the actual behavior so that full.names is respected by list.dirs, or the deprecation/new argument approach you suggested, and am happy to produce a patch to that effect. That, however, will have to wait for an indication from a member of R-core (which I'm not)  that such a change would be considered.
Comment 4 Duncan Murdoch 2013-08-27 18:33:31 UTC
Fixed by Brian Ripley in r63709.
Comment 5 Brian Ripley 2013-08-27 19:13:33 UTC
Looks like my comment never made it into the repository.

AFAIR I wrote 'as this has never worked, no one can be relying on it so I have now implemented it'