[Rd] non portable filenames
Henrik Bengtsson
hb at biostat.ucsf.edu
Thu Aug 30 22:47:26 CEST 2012
I think Kasper got a valid point and I'd second the idea of make R
accept tildes in filenames throughout. AFAIK, this is also compatible
with most file systems, cf. http://en.wikipedia.org/wiki/Filename
However, there will be some potentially ambiguous cases. For
instance, what if you have a directory named "~" in the current
directory. If you then refer to "~" from within the current
directory, should that have high priority than the current user's home
directory? I don't think so, because otherwise it would not be
possible to address that home directory. This is also how R does it
now as the following example illustrates:
# Create a local "~" directory
> dir.create("./~")
# Write a file to that directory
> cat(file="./~/foo.txt", "Hello world!\n");
# Read it
> readLines("./~/foo.txt")
[1] "Hello world!"
# Try to read it without the explicit "./" path.
> readLines("~/foo.txt")
Error in file(con, "r") : cannot open the connection
The latter will try to read foo.txt in the user's home directory.
/Henrik
On Mon, Aug 27, 2012 at 6:58 AM, Kasper Daniel Hansen
<kasperdanielhansen at gmail.com> wrote:
> I am including an external piece of software in an R package. This
> software ships with its own configure script generated by
> autoconf/automake, and this script is being run as part of the package
> configure script.
>
> The package contains a file
> m4/lt~obsolete.m4
> which - as far as I can see - is a standard file from the
> autoconf/automake/m4 suite of programs. A warning is generated with R
> CMD check about this filename being non-portable. Presumably because
> of the "~" in the file name. The users is referred to the 'Package
> structure' part of R-exts.
>
> Reading the manual, I do not see "~" listed in the beginning of the
> paragraph where non-allowed characters are described. Quoting:
>
> "To ensure that file names are valid across file systems and supported
> operating system platforms, the ASCII control characters as well as
> the characters ‘"’, ‘*’, ‘:’, ‘/’, ‘<’, ‘>’, ‘?’, ‘\’, and ‘|’ are not
> allowed in file names. In addition, files with names ‘con’, ‘prn’,
> ‘aux’, ‘clock$’, ‘nul’, ‘com1’ to ‘com9’, and ‘lpt1’ to ‘lpt9’ after
> conversion to lower case and stripping possible “extensions” (e.g.,
> ‘lpt5.foo.bar’), are disallowed. Also, file names in the same
> directory must not differ only by case (see the previous paragraph).
> In addition, the basenames of ‘.Rd’ files may be used in URLs and so
> must be ASCII and not contain %."
>
> However, "~" is also not part of the next sentence where allowed
> characters are listed. Quoting
>
> "For maximal portability filenames should only contain only ASCII
> characters not excluded already (that is A-Za-z0-9._!#$%&+,;=@^(){}'[]
> — we exclude space as many utilities do not accept spaces in file
> paths): non-English alphabetic characters cannot be guaranteed to be
> supported in all locales. It would be good practice to avoid the shell
> metacharacters (){}'[]$."
>
> To me it looks a bit like this paragraph is not self-consistent, since
> "~" is not listed as one of the characters already excluded.
>
> Now, I don't really know if "~" is portable. But I assume that the
> autoconf/automake/m4 people has thought a bit about this. And I don't
> really want to rename the file in question, as it is part of a lengthy
> configure script. So I guess my question is, is R CMD check correct
> in flagging the file? And what is recommended? I am tempted to
> ignore this warning, but I know warnings sometimes become errors.
>
> I assume other people might be in the same situation, since the
> filename originates from autoconf/automake/m4.
>
> Kasper
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list