[Rd] [R] Open a file which name contains a tilde
ccberry @end|ng |rom uc@d@edu
Fri Jun 7 18:08:28 CEST 2019
> On Jun 6, 2019, at 2:04 PM, Richard O'Keefe <raoknz using gmail.com> wrote:
> How can expanding tildes anywhere but the beginning of a file name NOT be
> considered a bug?
I think that that IS what libreadline is doing if one allows a whitespace separated list of file names.
As reported in R-help,
path.expand seems to expand tildes beginning whitespace separated strings that could be filenames, but not other tildes.
> path.expand("~/.newsrc ~/.R/*") # expands both tildes
 "/Users/cberry/.newsrc /Users/cberry/.R/*"
> path.expand("~/.newsrc~/.R/*") # expands only the first
This could be a feature if what one wanted was to pass the result to a system command that will process multiple file arguments, e.g.
> system(paste( "wc", path.expand("~/.newsrc ~/.R/*"))) # run wc on some files
I doubt that this was intended by R-core, but perhaps the readline devs had this in mind.
> On Thu, 6 Jun 2019 at 23:04, Ivan Krylov <krylov.r00t using gmail.com> wrote:
>> On Wed, 5 Jun 2019 18:07:15 +0200
>> Frank Schwidom <schwidom using gmx.net> wrote:
>>> +> path.expand("a ~ b")
>>>  "a /home/user b"
>>> How can I switch off any file crippling activity?
>> It doesn't seem to be possible if readline is enabled and works
>> Calls to path.expand  end up  in R_ExpandFileName , which
>> calls R_ExpandFileName_readline , which uses libreadline function
>> tilde_expand . tilde_expand seems to be designed to expand '~'
>> anywhere in the string it is handed, i.e. operate on whole command
>> lines, not file paths.
>> I am taking the liberty of Cc-ing R-devel in case this can be
>> considered a bug.
>> Best regards,
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
> [[alternative HTML version deleted]]
More information about the R-devel