[R] Bug in list.files(full.names=T)
Bill Dunlap
w||||@mwdun|@p @end|ng |rom gm@||@com
Mon Dec 20 19:02:32 CET 2021
> grep(value=TRUE, invert=TRUE, "\\\\$", strsplit(Sys.getenv("PATH"),
";")[[1]])
[1] "C:\\rtools40\\usr\\bin"
[2] "C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath"
[3] "C:\\Program Files\\ImageMagick-7.0.11-Q16-HDRI"
[4] "C:\\WINDOWS\\system32"
[5] "C:\\WINDOWS"
[6] "C:\\WINDOWS\\System32\\Wbem"
[7] "C:\\ProgramData\\chocolatey\\bin"
[8] "C:\\Program Files\\Git\\cmd"
[9] "C:\\Program Files\\TortoiseSVN\\bin"
[10] "C:\\Program Files\\Docker\\Docker\\resources\\bin"
[11] "C:\\ProgramData\\DockerDesktop\\version-bin"
[12] "C:\\Users\\willi\\AppData\\Local\\Microsoft\\WindowsApps"
[13] "C:\\Users\\willi\\AppData\\Local\\Programs\\Microsoft VS Code\\bin"
[14] "C:\\Users\\willi\\AppData\\Roaming\\npm"
[15] "C:\\Users\\willi\\AppData\\Local\\GitHubDesktop\\bin"
> table(grepl("\\\\$", strsplit(Sys.getenv("PATH"), ";")[[1]])) # c. 2:1
against terminal backslash
FALSE TRUE
15 8
On Mon, Dec 20, 2021 at 9:30 AM Martin Maechler <maechler using stat.math.ethz.ch>
wrote:
> >>>>> 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
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list