[R] Bug in list.files(full.names=T)

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Mon Dec 20 18:30:13 CET 2021


>>>>> Bill Dunlap 
>>>>>     on Mon, 20 Dec 2021 08:40:04 -0800 writes:

    >> 
    >> > Why would one ever *add* a final unneeded path separator,
    >> > unless one wanted it?
    >> 

    > Good question, but it is common for Windows installer programs to add a
    > terminal backslash to PATH entries.  E.g., on my Windows laptop I get

    >> grep(value=TRUE, "\\\\$", strsplit(Sys.getenv("PATH"), ";")[[1]])
    > [1] "C:\\Python39\\Scripts\\"
    > [2] "C:\\Python39\\"
    > [3] "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\"
    > [4] "C:\\WINDOWS\\System32\\OpenSSH\\"
    > [5] "C:\\Program Files\\nodejs\\"
    > [6] "C:\\Program Files\\Pandoc\\"
    > [7] "C:\\Program Files\\MiKTeX\\miktex\\bin\\x64\\"
    > [8] "C:\\Program Files\\PuTTY\\"

    > I did not add those entries by hand; all were added by installer programs.

    > -Bill

Thanks a lot, Bill,  for giving this part of the picture
(even though you did not show how many there were in your PATH which
 did *not* end in `\\` ..)

However the reason for my 2nd post was that I could *not* at all
confirm what Mario reported, but rather I saw
having a final "/" and not having it
to give the *same* behavior on R for Windows versions
from 3.6.1 to 4.1.2 on our M$ Windows terminal server (2016)
and now, as I just checked, it also *still* has the same Windows-specific
behavior in R-devel-ucrt (the one from Tomas Kalibera) :

If I use a trailing `/` or `\\` it is *kept*, but no additional
fsep (i.e. '/' or `\\`) is added (on Windows) when I use

     list.files(dir, full.names=TRUE)

contrary to what Mario reported (to happen in R 4.1.2, but not R 3.6.1)

Martin



More information about the R-help mailing list