Re: [R] Open a file which name contains a tilde

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Richard O'Keefe-2
How can expanding tildes anywhere but the beginning of a file name NOT be
considered a bug?


On Thu, 6 Jun 2019 at 23:04, Ivan Krylov <[hidden email]> wrote:

> On Wed, 5 Jun 2019 18:07:15 +0200
> Frank Schwidom <[hidden email]> wrote:
>
> > +> path.expand("a ~ b")
> > [1] "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
> correctly.
>
> Calls to path.expand [1] end up [2] in R_ExpandFileName [3], which
> calls R_ExpandFileName_readline [4], which uses libreadline function
> tilde_expand [5]. 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,
> Ivan
>
> [1]
>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>
> [2]
>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>
> [3]
>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>
> [4]
>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>
> [5]
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Duncan Murdoch-2
On 06/06/2019 5:04 p.m., Richard O'Keefe wrote:
> How can expanding tildes anywhere but the beginning of a file name NOT be
> considered a bug?

It looks like a bug in R, but not necessarily a bug in libreadline:  we
may just be using tilde_expand improperly.

Duncan Murdoch

>
>
> On Thu, 6 Jun 2019 at 23:04, Ivan Krylov <[hidden email]> wrote:
>
>> On Wed, 5 Jun 2019 18:07:15 +0200
>> Frank Schwidom <[hidden email]> wrote:
>>
>>> +> path.expand("a ~ b")
>>> [1] "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
>> correctly.
>>
>> Calls to path.expand [1] end up [2] in R_ExpandFileName [3], which
>> calls R_ExpandFileName_readline [4], which uses libreadline function
>> tilde_expand [5]. 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,
>> Ivan
>>
>> [1]
>>
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>
>> [2]
>>
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>
>> [3]
>>
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>
>> [4]
>>
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>
>> [5]
>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Richard O'Keefe-2
In reply to this post by Richard O'Keefe-2
?path.expand
    Expand a path name, for example by replacing a leading tilde by
    the user's home directory (if defined on that platform).

*A* path name.  The argument is a character vector.
If multiple path names are passed, they are passed

    On most builds of R *A LEADING* "~user" will be replaced...

Nothing is said in the R documentation about *multiple* or
*non-leading* tildes being replaced.

The actual behaviour is inconsistent with the documentation.
SOMETHING is a bug.

It's not clear to me why this is in any way dependent on
readline.  I've implemented tilde expansion several times
and always without readline.
It sounds as though R might be calling tilde_expand()
when it *should*, to be consistent with the documentation,
be calling tilde_expand_word().



as separate elements of the character vector.



On Sat, 8 Jun 2019 at 04:10, Berry, Charles <[hidden email]> wrote:

>
>
> > On Jun 6, 2019, at 2:04 PM, Richard O'Keefe <[hidden email]> 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,
>
>         https://www.mail-archive.com/r-help@.../msg254116.html
>
> path.expand seems to expand tildes beginning whitespace separated strings
> that could be filenames, but not other tildes.
>
> Thus,
>
> > path.expand("~/.newsrc ~/.R/*")  # expands both tildes
> [1] "/Users/cberry/.newsrc /Users/cberry/.R/*"
> > path.expand("~/.newsrc~/.R/*")   # expands only the first
> [1] "/Users/cberry/.newsrc~/.R/*"
> >
>
> 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.
>
> Chuck
>
>
> > On Thu, 6 Jun 2019 at 23:04, Ivan Krylov <[hidden email]> wrote:
> >
> >> On Wed, 5 Jun 2019 18:07:15 +0200
> >> Frank Schwidom <[hidden email]> wrote:
> >>
> >>> +> path.expand("a ~ b")
> >>> [1] "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
> >> correctly.
> >>
> >> Calls to path.expand [1] end up [2] in R_ExpandFileName [3], which
> >> calls R_ExpandFileName_readline [4], which uses libreadline function
> >> tilde_expand [5]. 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,
> >> Ivan
> >>
> >> [1]
> >>
> >>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >>
> >> [2]
> >>
> >>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >>
> >> [3]
> >>
> >>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >>
> >> [4]
> >>
> >>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >>
> >> [5]
> >>
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >>
> >> ______________________________________________
> >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >       [[alternative HTML version deleted]]
> >
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Gabriel Becker-2
In reply to this post by Richard O'Keefe-2
Hi Frank,

I'm hesitant to be "that guy", but in case no one else has brought this up
to you, having files with a tilde in their names (generally but especially
on a linux system, where ~ in file names has a very important special
meaning in some cases, as we know) strikes me as an exceptionally bad
practice anyway. In light of that, the solution with the smallest amount of
pain for you is almost surely to just... not do that. Your filenames will
be better for it anyway.

There is a reason no one has complained about this before, and while I
haven't run a study or anything, I strongly suspect its that "everyone"
else is already on the "no tildes in filenames" bandwagon, so this
behavior, even if technically a bug, has no ability to cause them problems.

Best,
~G

On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[hidden email]> wrote:

> Hi,
>
> yes, I have seen this package and it has the same tilde expanding problem.
>
> Please excuse me I will cc this answer to r-help and r-devel to keep the
> discussion running.
>
> Kind regards,
> Frank Schwidom
>
> On 2019-06-11 09:12:36, Gábor Csárdi wrote:
> > Just in case, have you seen the fs package?
> > https://fs.r-lib.org/
> >
> > Gabor
> >
> > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[hidden email]> wrote:
> > >
> > > Hi,
> > >
> > > to get rid of any possible filename modification I started a little
> project to cover my usecase:
> > >
> > > https://github.com/schwidom/simplefs
> > >
> > > This is my first R package, suggestions and a review are welcome.
> > >
> > > Thanks in advance
> > > Frank Schwidom
> > >
> > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
> > > >    How can expanding tildes anywhere but the beginning of a file
> name NOT be
> > > >    considered a bug?
> > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov <[1]
> [hidden email]> wrote:
> > > >
> > > >      On Wed, 5 Jun 2019 18:07:15 +0200
> > > >      Frank Schwidom <[2][hidden email]> wrote:
> > > >
> > > >      > +> path.expand("a ~ b")
> > > >      > [1] "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
> > > >      correctly.
> > > >
> > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName [3],
> which
> > > >      calls R_ExpandFileName_readline [4], which uses libreadline
> function
> > > >      tilde_expand [5]. 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,
> > > >      Ivan
> > > >
> > > >      [1]
> > > >      [3]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > > >
> > > >      [2]
> > > >      [4]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > > >
> > > >      [3]
> > > >      [5]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > > >
> > > >      [4]
> > > >      [6]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > > >
> > > >      [5]
> > > >      [7]
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > > >
> > > >      ______________________________________________
> > > >      [8][hidden email] mailing list -- To UNSUBSCRIBE and
> more, see
> > > >      [9]https://stat.ethz.ch/mailman/listinfo/r-help
> > > >      PLEASE do read the posting guide
> > > >      [10]http://www.R-project.org/posting-guide.html
> > > >      and provide commented, minimal, self-contained, reproducible
> code.
> > > >
> > > > References
> > > >
> > > >    Visible links
> > > >    1. mailto:[hidden email]
> > > >    2. mailto:[hidden email]
> > > >    3.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > > >    4.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > > >    5.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > > >    6.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > > >    7.
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > > >    8. mailto:[hidden email]
> > > >    9. https://stat.ethz.ch/mailman/listinfo/r-help
> > > >   10. http://www.r-project.org/posting-guide.html
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Travers Ching
Hi Gabriel,

It may be bad practice, but you don't always have control over the file
name.

E.g. if someone shares a file with a tilde in it -- yes it is simple to
rename but it is extra time, and you might not bother to rename a file
without foreknowledge of this bug in the first place.

Even worse, if someone points you to a read only location on a shared
server, you won't even be able to rename the file, and copying might be
prohibitive if it's a large file.

There are also tilde files created automatically by other programs, notably
microsoft office.

Travers




On Tue, Jun 11, 2019 at 9:49 AM Gabriel Becker <[hidden email]>
wrote:

> Hi Frank,
>
> I'm hesitant to be "that guy", but in case no one else has brought this up
> to you, having files with a tilde in their names (generally but especially
> on a linux system, where ~ in file names has a very important special
> meaning in some cases, as we know) strikes me as an exceptionally bad
> practice anyway. In light of that, the solution with the smallest amount of
> pain for you is almost surely to just... not do that. Your filenames will
> be better for it anyway.
>
> There is a reason no one has complained about this before, and while I
> haven't run a study or anything, I strongly suspect its that "everyone"
> else is already on the "no tildes in filenames" bandwagon, so this
> behavior, even if technically a bug, has no ability to cause them problems.
>
> Best,
> ~G
>
> On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[hidden email]> wrote:
>
> > Hi,
> >
> > yes, I have seen this package and it has the same tilde expanding
> problem.
> >
> > Please excuse me I will cc this answer to r-help and r-devel to keep the
> > discussion running.
> >
> > Kind regards,
> > Frank Schwidom
> >
> > On 2019-06-11 09:12:36, Gábor Csárdi wrote:
> > > Just in case, have you seen the fs package?
> > > https://fs.r-lib.org/
> > >
> > > Gabor
> > >
> > > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[hidden email]>
> wrote:
> > > >
> > > > Hi,
> > > >
> > > > to get rid of any possible filename modification I started a little
> > project to cover my usecase:
> > > >
> > > > https://github.com/schwidom/simplefs
> > > >
> > > > This is my first R package, suggestions and a review are welcome.
> > > >
> > > > Thanks in advance
> > > > Frank Schwidom
> > > >
> > > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
> > > > >    How can expanding tildes anywhere but the beginning of a file
> > name NOT be
> > > > >    considered a bug?
> > > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov <[1]
> > [hidden email]> wrote:
> > > > >
> > > > >      On Wed, 5 Jun 2019 18:07:15 +0200
> > > > >      Frank Schwidom <[2][hidden email]> wrote:
> > > > >
> > > > >      > +> path.expand("a ~ b")
> > > > >      > [1] "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
> > > > >      correctly.
> > > > >
> > > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName [3],
> > which
> > > > >      calls R_ExpandFileName_readline [4], which uses libreadline
> > function
> > > > >      tilde_expand [5]. 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,
> > > > >      Ivan
> > > > >
> > > > >      [1]
> > > > >      [3]
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > > > >
> > > > >      [2]
> > > > >      [4]
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > > > >
> > > > >      [3]
> > > > >      [5]
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > > > >
> > > > >      [4]
> > > > >      [6]
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > > > >
> > > > >      [5]
> > > > >      [7]
> > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > > > >
> > > > >      ______________________________________________
> > > > >      [8][hidden email] mailing list -- To UNSUBSCRIBE and
> > more, see
> > > > >      [9]https://stat.ethz.ch/mailman/listinfo/r-help
> > > > >      PLEASE do read the posting guide
> > > > >      [10]http://www.R-project.org/posting-guide.html
> > > > >      and provide commented, minimal, self-contained, reproducible
> > code.
> > > > >
> > > > > References
> > > > >
> > > > >    Visible links
> > > > >    1. mailto:[hidden email]
> > > > >    2. mailto:[hidden email]
> > > > >    3.
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > > > >    4.
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > > > >    5.
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > > > >    6.
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > > > >    7.
> > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > > > >    8. mailto:[hidden email]
> > > > >    9. https://stat.ethz.ch/mailman/listinfo/r-help
> > > > >   10. http://www.r-project.org/posting-guide.html
> > > >
> > > > ______________________________________________
> > > > [hidden email] mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-devel
> > >
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Frank Schwidom
In reply to this post by Gabriel Becker-2
Hi Gabriel,

I actually want to make renames over thousands of files. But if I am not able to express the source filename of the rename operation I will not be able to get the work done. Besides the fact that there are issues I think that R is qualified for solving my problem by the method how it can handle long vectors of strings, booleans and also lists.

Kind regards,
Frank

On 2019-06-11 09:49:17, Gabriel Becker wrote:

>    Hi Frank,
>    I'm hesitant to be "that guy", but in case no one else has brought this up
>    to you, having files with a tilde in their names (generally but especially
>    on a linux system, where ~ in file names has a very important special
>    meaning in some cases, as we know) strikes me as an exceptionally bad
>    practice anyway. In light of that, the solution with the smallest amount
>    of pain for you is almost surely to just... not do that. Your filenames
>    will be better for it anyway.
>    There is a reason no one has complained about this before, and while I
>    haven't run a study or anything, I strongly suspect its that "everyone"
>    else is already on the "no tildes in filenames" bandwagon, so this
>    behavior, even if technically a bug, has no ability to cause them
>    problems.
>    Best,
>    ~G
>    On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[1][hidden email]>
>    wrote:
>
>      Hi,
>
>      yes, I have seen this package and it has the same tilde expanding
>      problem.
>
>      Please excuse me I will cc this answer to r-help and r-devel to keep the
>      discussion running.
>
>      Kind regards,
>      Frank Schwidom
>
>      On 2019-06-11 09:12:36, Gábor Csárdi wrote:
>      > Just in case, have you seen the fs package?
>      > [2]https://fs.r-lib.org/
>      >
>      > Gabor
>      >
>      > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[3][hidden email]>
>      wrote:
>      > >
>      > > Hi,
>      > >
>      > > to get rid of any possible filename modification I started a little
>      project to cover my usecase:
>      > >
>      > > [4]https://github.com/schwidom/simplefs
>      > >
>      > > This is my first R package, suggestions and a review are welcome.
>      > >
>      > > Thanks in advance
>      > > Frank Schwidom
>      > >
>      > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
>      > > >    How can expanding tildes anywhere but the beginning of a file
>      name NOT be
>      > > >    considered a bug?
>      > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov
>      <[1][5][hidden email]> wrote:
>      > > >
>      > > >      On Wed, 5 Jun 2019 18:07:15 +0200
>      > > >      Frank Schwidom <[2][6][hidden email]> wrote:
>      > > >
>      > > >      > +> path.expand("a ~ b")
>      > > >      > [1] "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
>      > > >      correctly.
>      > > >
>      > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName [3],
>      which
>      > > >      calls R_ExpandFileName_readline [4], which uses libreadline
>      function
>      > > >      tilde_expand [5]. 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,
>      > > >      Ivan
>      > > >
>      > > >      [1]
>      > > >     
>      [3][7]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>      > > >
>      > > >      [2]
>      > > >     
>      [4][8]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>      > > >
>      > > >      [3]
>      > > >     
>      [5][9]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>      > > >
>      > > >      [4]
>      > > >     
>      [6][10]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>      > > >
>      > > >      [5]
>      > > >     
>      [7][11]https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>      > > >
>      > > >      ______________________________________________
>      > > >      [8][12][hidden email] mailing list -- To UNSUBSCRIBE
>      and more, see
>      > > >      [9][13]https://stat.ethz.ch/mailman/listinfo/r-help
>      > > >      PLEASE do read the posting guide
>      > > >      [10][14]http://www.R-project.org/posting-guide.html
>      > > >      and provide commented, minimal, self-contained, reproducible
>      code.
>      > > >
>      > > > References
>      > > >
>      > > >    Visible links
>      > > >    1. mailto:[15][hidden email]
>      > > >    2. mailto:[16][hidden email]
>      > > >    3.
>      [17]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>      > > >    4.
>      [18]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>      > > >    5.
>      [19]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>      > > >    6.
>      [20]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>      > > >    7.
>      [21]https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>      > > >    8. mailto:[22][hidden email]
>      > > >    9. [23]https://stat.ethz.ch/mailman/listinfo/r-help
>      > > >   10. [24]http://www.r-project.org/posting-guide.html
>      > >
>      > > ______________________________________________
>      > > [25][hidden email] mailing list
>      > > [26]https://stat.ethz.ch/mailman/listinfo/r-devel
>      >
>
>      ______________________________________________
>      [27][hidden email] mailing list
>      [28]https://stat.ethz.ch/mailman/listinfo/r-devel
>
> References
>
>    Visible links
>    1. mailto:[hidden email]
>    2. https://fs.r-lib.org/
>    3. mailto:[hidden email]
>    4. https://github.com/schwidom/simplefs
>    5. mailto:[hidden email]
>    6. mailto:[hidden email]
>    7. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>    8. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>    9. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>   10. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>   11. https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>   12. mailto:[hidden email]
>   13. https://stat.ethz.ch/mailman/listinfo/r-help
>   14. http://www.r-project.org/posting-guide.html
>   15. mailto:[hidden email]
>   16. mailto:[hidden email]
>   17. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>   18. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>   19. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>   20. https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>   21. https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>   22. mailto:[hidden email]
>   23. https://stat.ethz.ch/mailman/listinfo/r-help
>   24. http://www.r-project.org/posting-guide.html
>   25. mailto:[hidden email]
>   26. https://stat.ethz.ch/mailman/listinfo/r-devel
>   27. mailto:[hidden email]
>   28. https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

R devel mailing list
Note that R treats tildes in file names differently on Windows and Linux.
On Windows, it is only replaced if it it at the beginning of the line and
is followed by a forward or backward slash or end-of-line.  On Linux it is
replaced no matter where it is in the text and ~someUser will be replaced
by someUser's home directory (if 'someUser' is a user with a home
directory).

Hence, if you have a Windows machine that can look at the file system on
your Linux machine you can use file.rename on Windows to change the names.
My inclination would be to use a bash script on Linux to change the names,
but if you are not comfortable with bash try the Windows approach.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Tue, Jun 11, 2019 at 1:13 PM Frank Schwidom <[hidden email]> wrote:

> Hi Gabriel,
>
> I actually want to make renames over thousands of files. But if I am not
> able to express the source filename of the rename operation I will not be
> able to get the work done. Besides the fact that there are issues I think
> that R is qualified for solving my problem by the method how it can handle
> long vectors of strings, booleans and also lists.
>
> Kind regards,
> Frank
>
> On 2019-06-11 09:49:17, Gabriel Becker wrote:
> >    Hi Frank,
> >    I'm hesitant to be "that guy", but in case no one else has brought
> this up
> >    to you, having files with a tilde in their names (generally but
> especially
> >    on a linux system, where ~ in file names has a very important special
> >    meaning in some cases, as we know) strikes me as an exceptionally bad
> >    practice anyway. In light of that, the solution with the smallest
> amount
> >    of pain for you is almost surely to just... not do that. Your
> filenames
> >    will be better for it anyway.
> >    There is a reason no one has complained about this before, and while I
> >    haven't run a study or anything, I strongly suspect its that
> "everyone"
> >    else is already on the "no tildes in filenames" bandwagon, so this
> >    behavior, even if technically a bug, has no ability to cause them
> >    problems.
> >    Best,
> >    ~G
> >    On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[1][hidden email]>
> >    wrote:
> >
> >      Hi,
> >
> >      yes, I have seen this package and it has the same tilde expanding
> >      problem.
> >
> >      Please excuse me I will cc this answer to r-help and r-devel to
> keep the
> >      discussion running.
> >
> >      Kind regards,
> >      Frank Schwidom
> >
> >      On 2019-06-11 09:12:36, Gábor Csárdi wrote:
> >      > Just in case, have you seen the fs package?
> >      > [2]https://fs.r-lib.org/
> >      >
> >      > Gabor
> >      >
> >      > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[3]
> [hidden email]>
> >      wrote:
> >      > >
> >      > > Hi,
> >      > >
> >      > > to get rid of any possible filename modification I started a
> little
> >      project to cover my usecase:
> >      > >
> >      > > [4]https://github.com/schwidom/simplefs
> >      > >
> >      > > This is my first R package, suggestions and a review are
> welcome.
> >      > >
> >      > > Thanks in advance
> >      > > Frank Schwidom
> >      > >
> >      > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
> >      > > >    How can expanding tildes anywhere but the beginning of a
> file
> >      name NOT be
> >      > > >    considered a bug?
> >      > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov
> >      <[1][5][hidden email]> wrote:
> >      > > >
> >      > > >      On Wed, 5 Jun 2019 18:07:15 +0200
> >      > > >      Frank Schwidom <[2][6][hidden email]> wrote:
> >      > > >
> >      > > >      > +> path.expand("a ~ b")
> >      > > >      > [1] "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
> >      > > >      correctly.
> >      > > >
> >      > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName
> [3],
> >      which
> >      > > >      calls R_ExpandFileName_readline [4], which uses
> libreadline
> >      function
> >      > > >      tilde_expand [5]. 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,
> >      > > >      Ivan
> >      > > >
> >      > > >      [1]
> >      > > >
> >      [3][7]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >      > > >
> >      > > >      [2]
> >      > > >
> >      [4][8]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >      > > >
> >      > > >      [3]
> >      > > >
> >      [5][9]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >      > > >
> >      > > >      [4]
> >      > > >
> >      [6][10]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >      > > >
> >      > > >      [5]
> >      > > >
> >      [7][11]
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >      > > >
> >      > > >      ______________________________________________
> >      > > >      [8][12][hidden email] mailing list -- To
> UNSUBSCRIBE
> >      and more, see
> >      > > >      [9][13]https://stat.ethz.ch/mailman/listinfo/r-help
> >      > > >      PLEASE do read the posting guide
> >      > > >      [10][14]http://www.R-project.org/posting-guide.html
> >      > > >      and provide commented, minimal, self-contained,
> reproducible
> >      code.
> >      > > >
> >      > > > References
> >      > > >
> >      > > >    Visible links
> >      > > >    1. mailto:[15][hidden email]
> >      > > >    2. mailto:[16][hidden email]
> >      > > >    3.
> >      [17]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >      > > >    4.
> >      [18]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >      > > >    5.
> >      [19]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >      > > >    6.
> >      [20]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >      > > >    7.
> >      [21]
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >      > > >    8. mailto:[22][hidden email]
> >      > > >    9. [23]https://stat.ethz.ch/mailman/listinfo/r-help
> >      > > >   10. [24]http://www.r-project.org/posting-guide.html
> >      > >
> >      > > ______________________________________________
> >      > > [25][hidden email] mailing list
> >      > > [26]https://stat.ethz.ch/mailman/listinfo/r-devel
> >      >
> >
> >      ______________________________________________
> >      [27][hidden email] mailing list
> >      [28]https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > References
> >
> >    Visible links
> >    1. mailto:[hidden email]
> >    2. https://fs.r-lib.org/
> >    3. mailto:[hidden email]
> >    4. https://github.com/schwidom/simplefs
> >    5. mailto:[hidden email]
> >    6. mailto:[hidden email]
> >    7.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >    8.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >    9.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >   10.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >   11.
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >   12. mailto:[hidden email]
> >   13. https://stat.ethz.ch/mailman/listinfo/r-help
> >   14. http://www.r-project.org/posting-guide.html
> >   15. mailto:[hidden email]
> >   16. mailto:[hidden email]
> >   17.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >   18.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >   19.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >   20.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >   21.
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >   22. mailto:[hidden email]
> >   23. https://stat.ethz.ch/mailman/listinfo/r-help
> >   24. http://www.r-project.org/posting-guide.html
> >   25. mailto:[hidden email]
> >   26. https://stat.ethz.ch/mailman/listinfo/r-devel
> >   27. mailto:[hidden email]
> >   28. https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Kurt Hornik-5
>>>>> Duncan Murdoch writes:

With c76695 in the trunk, we now only tilde expand file names starting
with a tilde also when using readline.

Best
-k

> On 11/06/2019 4:34 p.m., William Dunlap via R-devel wrote:
>> Note that R treats tildes in file names differently on Windows and Linux.
>> On Windows, it is only replaced if it it at the beginning of the line and
>> is followed by a forward or backward slash or end-of-line.  On Linux it is
>> replaced no matter where it is in the text and ~someUser will be replaced
>> by someUser's home directory (if 'someUser' is a user with a home
>> directory).

> That's not quite true:  On Linux the bug is in the code that uses
> libreadline, which you don't have to use.  If you just specify
> "--no-readline" when you start R, it will be fine on Linux, as far as I
> can see.

> I wouldn't choose that as the default way to run R (it's pretty
> irritating not to have readline support), but it is a workaround for
> this bug.

> Duncan Murdoch

>>
>> Hence, if you have a Windows machine that can look at the file system on
>> your Linux machine you can use file.rename on Windows to change the names.
>> My inclination would be to use a bash script on Linux to change the names,
>> but if you are not comfortable with bash try the Windows approach.
>>
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>>
>>
>> On Tue, Jun 11, 2019 at 1:13 PM Frank Schwidom <[hidden email]> wrote:
>>
>>> Hi Gabriel,
>>>
>>> I actually want to make renames over thousands of files. But if I am not
>>> able to express the source filename of the rename operation I will not be
>>> able to get the work done. Besides the fact that there are issues I think
>>> that R is qualified for solving my problem by the method how it can handle
>>> long vectors of strings, booleans and also lists.
>>>
>>> Kind regards,
>>> Frank
>>>
>>> On 2019-06-11 09:49:17, Gabriel Becker wrote:
>>>> Hi Frank,
>>>> I'm hesitant to be "that guy", but in case no one else has brought
>>> this up
>>>> to you, having files with a tilde in their names (generally but
>>> especially
>>>> on a linux system, where ~ in file names has a very important special
>>>> meaning in some cases, as we know) strikes me as an exceptionally bad
>>>> practice anyway. In light of that, the solution with the smallest
>>> amount
>>>> of pain for you is almost surely to just... not do that. Your
>>> filenames
>>>> will be better for it anyway.
>>>> There is a reason no one has complained about this before, and while I
>>>> haven't run a study or anything, I strongly suspect its that
>>> "everyone"
>>>> else is already on the "no tildes in filenames" bandwagon, so this
>>>> behavior, even if technically a bug, has no ability to cause them
>>>> problems.
>>>> Best,
>>>> ~G
>>>> On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[1][hidden email]>
>>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> yes, I have seen this package and it has the same tilde expanding
>>>> problem.
>>>>
>>>> Please excuse me I will cc this answer to r-help and r-devel to
>>> keep the
>>>> discussion running.
>>>>
>>>> Kind regards,
>>>> Frank Schwidom
>>>>
>>>> On 2019-06-11 09:12:36, Gábor Csárdi wrote:
>>>> > Just in case, have you seen the fs package?
>>>> > [2]https://fs.r-lib.org/
>>>> >
>>>> > Gabor
>>>> >
>>>> > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[3]
>>> [hidden email]>
>>>> wrote:
>>>> > >
>>>> > > Hi,
>>>> > >
>>>> > > to get rid of any possible filename modification I started a
>>> little
>>>> project to cover my usecase:
>>>> > >
>>>> > > [4]https://github.com/schwidom/simplefs
>>>> > >
>>>> > > This is my first R package, suggestions and a review are
>>> welcome.
>>>> > >
>>>> > > Thanks in advance
>>>> > > Frank Schwidom
>>>> > >
>>>> > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
>>>> > > >    How can expanding tildes anywhere but the beginning of a
>>> file
>>>> name NOT be
>>>> > > >    considered a bug?
>>>> > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov
>>>> <[1][5][hidden email]> wrote:
>>>> > > >
>>>> > > >      On Wed, 5 Jun 2019 18:07:15 +0200
>>>> > > >      Frank Schwidom <[2][6][hidden email]> wrote:
>>>> > > >
>>>> > > >      > +> path.expand("a ~ b")
>>>> > > >      > [1] "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
>>>> > > >      correctly.
>>>> > > >
>>>> > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName
>>> [3],
>>>> which
>>>> > > >      calls R_ExpandFileName_readline [4], which uses
>>> libreadline
>>>> function
>>>> > > >      tilde_expand [5]. 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,
>>>> > > >      Ivan
>>>> > > >
>>>> > > >      [1]
>>>> > > >
>>>> [3][7]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>>> > > >
>>>> > > >      [2]
>>>> > > >
>>>> [4][8]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>>> > > >
>>>> > > >      [3]
>>>> > > >
>>>> [5][9]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>>> > > >
>>>> > > >      [4]
>>>> > > >
>>>> [6][10]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>>> > > >
>>>> > > >      [5]
>>>> > > >
>>>> [7][11]
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>>> > > >
>>>> > > >      ______________________________________________
>>>> > > >      [8][12][hidden email] mailing list -- To
>>> UNSUBSCRIBE
>>>> and more, see
>>>> > > >      [9][13]https://stat.ethz.ch/mailman/listinfo/r-help
>>>> > > >      PLEASE do read the posting guide
>>>> > > >      [10][14]http://www.R-project.org/posting-guide.html
>>>> > > >      and provide commented, minimal, self-contained,
>>> reproducible
>>>> code.
>>>> > > >
>>>> > > > References
>>>> > > >
>>>> > > >    Visible links
>>>> > > >    1. mailto:[15][hidden email]
>>>> > > >    2. mailto:[16][hidden email]
>>>> > > >    3.
>>>> [17]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>>> > > >    4.
>>>> [18]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>>> > > >    5.
>>>> [19]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>>> > > >    6.
>>>> [20]
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>>> > > >    7.
>>>> [21]
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>>> > > >    8. mailto:[22][hidden email]
>>>> > > >    9. [23]https://stat.ethz.ch/mailman/listinfo/r-help
>>>> > > >   10. [24]http://www.r-project.org/posting-guide.html
>>>> > >
>>>> > > ______________________________________________
>>>> > > [25][hidden email] mailing list
>>>> > > [26]https://stat.ethz.ch/mailman/listinfo/r-devel
>>>> >
>>>>
>>>> ______________________________________________
>>>> [27][hidden email] mailing list
>>>> [28]https://stat.ethz.ch/mailman/listinfo/r-devel
>>>>
>>>> References
>>>>
>>>> Visible links
>>>> 1. mailto:[hidden email]
>>>> 2. https://fs.r-lib.org/
>>>> 3. mailto:[hidden email]
>>>> 4. https://github.com/schwidom/simplefs
>>>> 5. mailto:[hidden email]
>>>> 6. mailto:[hidden email]
>>>> 7.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>>> 8.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>>> 9.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>>> 10.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>>> 11.
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>>> 12. mailto:[hidden email]
>>>> 13. https://stat.ethz.ch/mailman/listinfo/r-help
>>>> 14. http://www.r-project.org/posting-guide.html
>>>> 15. mailto:[hidden email]
>>>> 16. mailto:[hidden email]
>>>> 17.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>>> 18.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>>> 19.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>>> 20.
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>>> 21.
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>>> 22. mailto:[hidden email]
>>>> 23. https://stat.ethz.ch/mailman/listinfo/r-help
>>>> 24. http://www.r-project.org/posting-guide.html
>>>> 25. mailto:[hidden email]
>>>> 26. https://stat.ethz.ch/mailman/listinfo/r-devel
>>>> 27. mailto:[hidden email]
>>>> 28. https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>

> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Paul McQuesten
@ Gabriel:

"Avoid tilde in file names":
Not quite.
A tilde *suffix* is commonly used by *nix editors for backup files
https://unix.stackexchange.com/questions/76189/what-does-the-tilde-mean-at-the-end-of-a-filename

On Wed, Jun 12, 2019 at 2:43 AM Kurt Hornik <[hidden email]> wrote:

> >>>>> Duncan Murdoch writes:
>
> With c76695 in the trunk, we now only tilde expand file names starting
> with a tilde also when using readline.
>
> Best
> -k
>
> > On 11/06/2019 4:34 p.m., William Dunlap via R-devel wrote:
> >> Note that R treats tildes in file names differently on Windows and
> Linux.
> >> On Windows, it is only replaced if it it at the beginning of the line
> and
> >> is followed by a forward or backward slash or end-of-line.  On Linux it
> is
> >> replaced no matter where it is in the text and ~someUser will be
> replaced
> >> by someUser's home directory (if 'someUser' is a user with a home
> >> directory).
>
> > That's not quite true:  On Linux the bug is in the code that uses
> > libreadline, which you don't have to use.  If you just specify
> > "--no-readline" when you start R, it will be fine on Linux, as far as I
> > can see.
>
> > I wouldn't choose that as the default way to run R (it's pretty
> > irritating not to have readline support), but it is a workaround for
> > this bug.
>
> > Duncan Murdoch
>
> >>
> >> Hence, if you have a Windows machine that can look at the file system on
> >> your Linux machine you can use file.rename on Windows to change the
> names.
> >> My inclination would be to use a bash script on Linux to change the
> names,
> >> but if you are not comfortable with bash try the Windows approach.
> >>
> >> Bill Dunlap
> >> TIBCO Software
> >> wdunlap tibco.com
> >>
> >>
> >> On Tue, Jun 11, 2019 at 1:13 PM Frank Schwidom <[hidden email]>
> wrote:
> >>
> >>> Hi Gabriel,
> >>>
> >>> I actually want to make renames over thousands of files. But if I am
> not
> >>> able to express the source filename of the rename operation I will not
> be
> >>> able to get the work done. Besides the fact that there are issues I
> think
> >>> that R is qualified for solving my problem by the method how it can
> handle
> >>> long vectors of strings, booleans and also lists.
> >>>
> >>> Kind regards,
> >>> Frank
> >>>
> >>> On 2019-06-11 09:49:17, Gabriel Becker wrote:
> >>>> Hi Frank,
> >>>> I'm hesitant to be "that guy", but in case no one else has brought
> >>> this up
> >>>> to you, having files with a tilde in their names (generally but
> >>> especially
> >>>> on a linux system, where ~ in file names has a very important special
> >>>> meaning in some cases, as we know) strikes me as an exceptionally bad
> >>>> practice anyway. In light of that, the solution with the smallest
> >>> amount
> >>>> of pain for you is almost surely to just... not do that. Your
> >>> filenames
> >>>> will be better for it anyway.
> >>>> There is a reason no one has complained about this before, and while I
> >>>> haven't run a study or anything, I strongly suspect its that
> >>> "everyone"
> >>>> else is already on the "no tildes in filenames" bandwagon, so this
> >>>> behavior, even if technically a bug, has no ability to cause them
> >>>> problems.
> >>>> Best,
> >>>> ~G
> >>>> On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[1][hidden email]>
> >>>> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> yes, I have seen this package and it has the same tilde expanding
> >>>> problem.
> >>>>
> >>>> Please excuse me I will cc this answer to r-help and r-devel to
> >>> keep the
> >>>> discussion running.
> >>>>
> >>>> Kind regards,
> >>>> Frank Schwidom
> >>>>
> >>>> On 2019-06-11 09:12:36, Gábor Csárdi wrote:
> >>>> > Just in case, have you seen the fs package?
> >>>> > [2]https://fs.r-lib.org/
> >>>> >
> >>>> > Gabor
> >>>> >
> >>>> > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[3]
> >>> [hidden email]>
> >>>> wrote:
> >>>> > >
> >>>> > > Hi,
> >>>> > >
> >>>> > > to get rid of any possible filename modification I started a
> >>> little
> >>>> project to cover my usecase:
> >>>> > >
> >>>> > > [4]https://github.com/schwidom/simplefs
> >>>> > >
> >>>> > > This is my first R package, suggestions and a review are
> >>> welcome.
> >>>> > >
> >>>> > > Thanks in advance
> >>>> > > Frank Schwidom
> >>>> > >
> >>>> > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
> >>>> > > >    How can expanding tildes anywhere but the beginning of a
> >>> file
> >>>> name NOT be
> >>>> > > >    considered a bug?
> >>>> > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov
> >>>> <[1][5][hidden email]> wrote:
> >>>> > > >
> >>>> > > >      On Wed, 5 Jun 2019 18:07:15 +0200
> >>>> > > >      Frank Schwidom <[2][6][hidden email]> wrote:
> >>>> > > >
> >>>> > > >      > +> path.expand("a ~ b")
> >>>> > > >      > [1] "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
> >>>> > > >      correctly.
> >>>> > > >
> >>>> > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName
> >>> [3],
> >>>> which
> >>>> > > >      calls R_ExpandFileName_readline [4], which uses
> >>> libreadline
> >>>> function
> >>>> > > >      tilde_expand [5]. 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,
> >>>> > > >      Ivan
> >>>> > > >
> >>>> > > >      [1]
> >>>> > > >
> >>>> [3][7]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >>>> > > >
> >>>> > > >      [2]
> >>>> > > >
> >>>> [4][8]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >>>> > > >
> >>>> > > >      [3]
> >>>> > > >
> >>>> [5][9]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >>>> > > >
> >>>> > > >      [4]
> >>>> > > >
> >>>> [6][10]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >>>> > > >
> >>>> > > >      [5]
> >>>> > > >
> >>>> [7][11]
> >>>
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >>>> > > >
> >>>> > > >      ______________________________________________
> >>>> > > >      [8][12][hidden email] mailing list -- To
> >>> UNSUBSCRIBE
> >>>> and more, see
> >>>> > > >      [9][13]https://stat.ethz.ch/mailman/listinfo/r-help
> >>>> > > >      PLEASE do read the posting guide
> >>>> > > >      [10][14]http://www.R-project.org/posting-guide.html
> >>>> > > >      and provide commented, minimal, self-contained,
> >>> reproducible
> >>>> code.
> >>>> > > >
> >>>> > > > References
> >>>> > > >
> >>>> > > >    Visible links
> >>>> > > >    1. mailto:[15][hidden email]
> >>>> > > >    2. mailto:[16][hidden email]
> >>>> > > >    3.
> >>>> [17]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >>>> > > >    4.
> >>>> [18]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >>>> > > >    5.
> >>>> [19]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >>>> > > >    6.
> >>>> [20]
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >>>> > > >    7.
> >>>> [21]
> >>>
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >>>> > > >    8. mailto:[22][hidden email]
> >>>> > > >    9. [23]https://stat.ethz.ch/mailman/listinfo/r-help
> >>>> > > >   10. [24]http://www.r-project.org/posting-guide.html
> >>>> > >
> >>>> > > ______________________________________________
> >>>> > > [25][hidden email] mailing list
> >>>> > > [26]https://stat.ethz.ch/mailman/listinfo/r-devel
> >>>> >
> >>>>
> >>>> ______________________________________________
> >>>> [27][hidden email] mailing list
> >>>> [28]https://stat.ethz.ch/mailman/listinfo/r-devel
> >>>>
> >>>> References
> >>>>
> >>>> Visible links
> >>>> 1. mailto:[hidden email]
> >>>> 2. https://fs.r-lib.org/
> >>>> 3. mailto:[hidden email]
> >>>> 4. https://github.com/schwidom/simplefs
> >>>> 5. mailto:[hidden email]
> >>>> 6. mailto:[hidden email]
> >>>> 7.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >>>> 8.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >>>> 9.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >>>> 10.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >>>> 11.
> >>>
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >>>> 12. mailto:[hidden email]
> >>>> 13. https://stat.ethz.ch/mailman/listinfo/r-help
> >>>> 14. http://www.r-project.org/posting-guide.html
> >>>> 15. mailto:[hidden email]
> >>>> 16. mailto:[hidden email]
> >>>> 17.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> >>>> 18.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> >>>> 19.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> >>>> 20.
> >>>
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> >>>> 21.
> >>>
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> >>>> 22. mailto:[hidden email]
> >>>> 23. https://stat.ethz.ch/mailman/listinfo/r-help
> >>>> 24. http://www.r-project.org/posting-guide.html
> >>>> 25. mailto:[hidden email]
> >>>> 26. https://stat.ethz.ch/mailman/listinfo/r-devel
> >>>> 27. mailto:[hidden email]
> >>>> 28. https://stat.ethz.ch/mailman/listinfo/r-devel
> >>>
> >>> ______________________________________________
> >>> [hidden email] mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>>
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
>
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Gabriel Becker-2
On Wed, Jun 12, 2019, 5:16 AM Paul McQuesten <[hidden email]> wrote:

> @ Gabriel:
>
> "Avoid tilde in file names":
> Not quite.
> A tilde *suffix* is commonly used by *nix editors for backup files
>
> https://unix.stackexchange.com/questions/76189/what-does-the-tilde-mean-at-the-end-of-a-filename


I'm aware of that, but that isn't the case that is being discussed, as the
example given clearly had a tilde (and spaces) in the middle of the file.
Backup files witilde suffix does not trigger the bug being discussed. It's
*only* files paths where the tilde is surrounded on both by spaces (or on
the right by the end fo the string) that trigger it.

> path.expand("a~b")

[1] "a~b"

> path.expand("a ~ b")

[1] "a /Users/gabrielbecker b"

> path.expand("myfile.txt~")

[1] "myfile.txt~"

> path.expand("myfile.txt ~")

[1] "myfile.txt /Users/gabrielbecker"


All that said I'm really not interested in participating in a flame war
over this. I gave my 2 cents as respectfully as I could, so as of now
please consider my participation  and interest in this thread closed.

Best,
~G



>
>
>
> On Wed, Jun 12, 2019 at 2:43 AM Kurt Hornik <[hidden email]> wrote:
>
> > >>>>> Duncan Murdoch writes:
> >
> > With c76695 in the trunk, we now only tilde expand file names starting
> > with a tilde also when using readline.
> >
> > Best
> > -k
> >
> > > On 11/06/2019 4:34 p.m., William Dunlap via R-devel wrote:
> > >> Note that R treats tildes in file names differently on Windows and
> > Linux.
> > >> On Windows, it is only replaced if it it at the beginning of the line
> > and
> > >> is followed by a forward or backward slash or end-of-line.  On Linux
> it
> > is
> > >> replaced no matter where it is in the text and ~someUser will be
> > replaced
> > >> by someUser's home directory (if 'someUser' is a user with a home
> > >> directory).
> >
> > > That's not quite true:  On Linux the bug is in the code that uses
> > > libreadline, which you don't have to use.  If you just specify
> > > "--no-readline" when you start R, it will be fine on Linux, as far as I
> > > can see.
> >
> > > I wouldn't choose that as the default way to run R (it's pretty
> > > irritating not to have readline support), but it is a workaround for
> > > this bug.
> >
> > > Duncan Murdoch
> >
> > >>
> > >> Hence, if you have a Windows machine that can look at the file system
> on
> > >> your Linux machine you can use file.rename on Windows to change the
> > names.
> > >> My inclination would be to use a bash script on Linux to change the
> > names,
> > >> but if you are not comfortable with bash try the Windows approach.
> > >>
> > >> Bill Dunlap
> > >> TIBCO Software
> > >> wdunlap tibco.com
> > >>
> > >>
> > >> On Tue, Jun 11, 2019 at 1:13 PM Frank Schwidom <[hidden email]>
> > wrote:
> > >>
> > >>> Hi Gabriel,
> > >>>
> > >>> I actually want to make renames over thousands of files. But if I am
> > not
> > >>> able to express the source filename of the rename operation I will
> not
> > be
> > >>> able to get the work done. Besides the fact that there are issues I
> > think
> > >>> that R is qualified for solving my problem by the method how it can
> > handle
> > >>> long vectors of strings, booleans and also lists.
> > >>>
> > >>> Kind regards,
> > >>> Frank
> > >>>
> > >>> On 2019-06-11 09:49:17, Gabriel Becker wrote:
> > >>>> Hi Frank,
> > >>>> I'm hesitant to be "that guy", but in case no one else has brought
> > >>> this up
> > >>>> to you, having files with a tilde in their names (generally but
> > >>> especially
> > >>>> on a linux system, where ~ in file names has a very important
> special
> > >>>> meaning in some cases, as we know) strikes me as an exceptionally
> bad
> > >>>> practice anyway. In light of that, the solution with the smallest
> > >>> amount
> > >>>> of pain for you is almost surely to just... not do that. Your
> > >>> filenames
> > >>>> will be better for it anyway.
> > >>>> There is a reason no one has complained about this before, and
> while I
> > >>>> haven't run a study or anything, I strongly suspect its that
> > >>> "everyone"
> > >>>> else is already on the "no tildes in filenames" bandwagon, so this
> > >>>> behavior, even if technically a bug, has no ability to cause them
> > >>>> problems.
> > >>>> Best,
> > >>>> ~G
> > >>>> On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[1][hidden email]
> >
> > >>>> wrote:
> > >>>>
> > >>>> Hi,
> > >>>>
> > >>>> yes, I have seen this package and it has the same tilde expanding
> > >>>> problem.
> > >>>>
> > >>>> Please excuse me I will cc this answer to r-help and r-devel to
> > >>> keep the
> > >>>> discussion running.
> > >>>>
> > >>>> Kind regards,
> > >>>> Frank Schwidom
> > >>>>
> > >>>> On 2019-06-11 09:12:36, Gábor Csárdi wrote:
> > >>>> > Just in case, have you seen the fs package?
> > >>>> > [2]https://fs.r-lib.org/
> > >>>> >
> > >>>> > Gabor
> > >>>> >
> > >>>> > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[3]
> > >>> [hidden email]>
> > >>>> wrote:
> > >>>> > >
> > >>>> > > Hi,
> > >>>> > >
> > >>>> > > to get rid of any possible filename modification I started a
> > >>> little
> > >>>> project to cover my usecase:
> > >>>> > >
> > >>>> > > [4]https://github.com/schwidom/simplefs
> > >>>> > >
> > >>>> > > This is my first R package, suggestions and a review are
> > >>> welcome.
> > >>>> > >
> > >>>> > > Thanks in advance
> > >>>> > > Frank Schwidom
> > >>>> > >
> > >>>> > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
> > >>>> > > >    How can expanding tildes anywhere but the beginning of a
> > >>> file
> > >>>> name NOT be
> > >>>> > > >    considered a bug?
> > >>>> > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov
> > >>>> <[1][5][hidden email]> wrote:
> > >>>> > > >
> > >>>> > > >      On Wed, 5 Jun 2019 18:07:15 +0200
> > >>>> > > >      Frank Schwidom <[2][6][hidden email]> wrote:
> > >>>> > > >
> > >>>> > > >      > +> path.expand("a ~ b")
> > >>>> > > >      > [1] "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
> > >>>> > > >      correctly.
> > >>>> > > >
> > >>>> > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName
> > >>> [3],
> > >>>> which
> > >>>> > > >      calls R_ExpandFileName_readline [4], which uses
> > >>> libreadline
> > >>>> function
> > >>>> > > >      tilde_expand [5]. 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,
> > >>>> > > >      Ivan
> > >>>> > > >
> > >>>> > > >      [1]
> > >>>> > > >
> > >>>> [3][7]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > >>>> > > >
> > >>>> > > >      [2]
> > >>>> > > >
> > >>>> [4][8]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > >>>> > > >
> > >>>> > > >      [3]
> > >>>> > > >
> > >>>> [5][9]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > >>>> > > >
> > >>>> > > >      [4]
> > >>>> > > >
> > >>>> [6][10]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > >>>> > > >
> > >>>> > > >      [5]
> > >>>> > > >
> > >>>> [7][11]
> > >>>
> > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > >>>> > > >
> > >>>> > > >      ______________________________________________
> > >>>> > > >      [8][12][hidden email] mailing list -- To
> > >>> UNSUBSCRIBE
> > >>>> and more, see
> > >>>> > > >      [9][13]https://stat.ethz.ch/mailman/listinfo/r-help
> > >>>> > > >      PLEASE do read the posting guide
> > >>>> > > >      [10][14]http://www.R-project.org/posting-guide.html
> > >>>> > > >      and provide commented, minimal, self-contained,
> > >>> reproducible
> > >>>> code.
> > >>>> > > >
> > >>>> > > > References
> > >>>> > > >
> > >>>> > > >    Visible links
> > >>>> > > >    1. mailto:[15][hidden email]
> > >>>> > > >    2. mailto:[16][hidden email]
> > >>>> > > >    3.
> > >>>> [17]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > >>>> > > >    4.
> > >>>> [18]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > >>>> > > >    5.
> > >>>> [19]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > >>>> > > >    6.
> > >>>> [20]
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > >>>> > > >    7.
> > >>>> [21]
> > >>>
> > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > >>>> > > >    8. mailto:[22][hidden email]
> > >>>> > > >    9. [23]https://stat.ethz.ch/mailman/listinfo/r-help
> > >>>> > > >   10. [24]http://www.r-project.org/posting-guide.html
> > >>>> > >
> > >>>> > > ______________________________________________
> > >>>> > > [25][hidden email] mailing list
> > >>>> > > [26]https://stat.ethz.ch/mailman/listinfo/r-devel
> > >>>> >
> > >>>>
> > >>>> ______________________________________________
> > >>>> [27][hidden email] mailing list
> > >>>> [28]https://stat.ethz.ch/mailman/listinfo/r-devel
> > >>>>
> > >>>> References
> > >>>>
> > >>>> Visible links
> > >>>> 1. mailto:[hidden email]
> > >>>> 2. https://fs.r-lib.org/
> > >>>> 3. mailto:[hidden email]
> > >>>> 4. https://github.com/schwidom/simplefs
> > >>>> 5. mailto:[hidden email]
> > >>>> 6. mailto:[hidden email]
> > >>>> 7.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > >>>> 8.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > >>>> 9.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > >>>> 10.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > >>>> 11.
> > >>>
> > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > >>>> 12. mailto:[hidden email]
> > >>>> 13. https://stat.ethz.ch/mailman/listinfo/r-help
> > >>>> 14. http://www.r-project.org/posting-guide.html
> > >>>> 15. mailto:[hidden email]
> > >>>> 16. mailto:[hidden email]
> > >>>> 17.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
> > >>>> 18.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
> > >>>> 19.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > >>>> 20.
> > >>>
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > >>>> 21.
> > >>>
> > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > >>>> 22. mailto:[hidden email]
> > >>>> 23. https://stat.ethz.ch/mailman/listinfo/r-help
> > >>>> 24. http://www.r-project.org/posting-guide.html
> > >>>> 25. mailto:[hidden email]
> > >>>> 26. https://stat.ethz.ch/mailman/listinfo/r-devel
> > >>>> 27. mailto:[hidden email]
> > >>>> 28. https://stat.ethz.ch/mailman/listinfo/r-devel
> > >>>
> > >>> ______________________________________________
> > >>> [hidden email] mailing list
> > >>> https://stat.ethz.ch/mailman/listinfo/r-devel
> > >>>
> > >>
> > >> [[alternative HTML version deleted]]
> > >>
> > >> ______________________________________________
> > >> [hidden email] mailing list
> > >> https://stat.ethz.ch/mailman/listinfo/r-devel
> > >>
> >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Gabriel Becker-2
At the risk of looking silly, note that all of this is now largely moot
anyway (or will be with the next release of R), thanks to Kurt Hornik's
fixing of the bug in question (which he announced on this thread prior to
but I read after Paul's).

~G

On Wed, Jun 12, 2019 at 11:51 PM Gabriel Becker <[hidden email]>
wrote:

>
>
> On Wed, Jun 12, 2019, 5:16 AM Paul McQuesten <[hidden email]> wrote:
>
>> @ Gabriel:
>>
>> "Avoid tilde in file names":
>> Not quite.
>> A tilde *suffix* is commonly used by *nix editors for backup files
>>
>> https://unix.stackexchange.com/questions/76189/what-does-the-tilde-mean-at-the-end-of-a-filename
>
>
> I'm aware of that, but that isn't the case that is being discussed, as the
> example given clearly had a tilde (and spaces) in the middle of the file.
> Backup files witilde suffix does not trigger the bug being discussed. It's
> *only* files paths where the tilde is surrounded on both by spaces (or on
> the right by the end fo the string) that trigger it.
>
> > path.expand("a~b")
>
> [1] "a~b"
>
> > path.expand("a ~ b")
>
> [1] "a /Users/gabrielbecker b"
>
> > path.expand("myfile.txt~")
>
> [1] "myfile.txt~"
>
> > path.expand("myfile.txt ~")
>
> [1] "myfile.txt /Users/gabrielbecker"
>
>
> All that said I'm really not interested in participating in a flame war
> over this. I gave my 2 cents as respectfully as I could, so as of now
> please consider my participation  and interest in this thread closed.
>
> Best,
> ~G
>
>
>
>>
>>
>>
>> On Wed, Jun 12, 2019 at 2:43 AM Kurt Hornik <[hidden email]> wrote:
>>
>> > >>>>> Duncan Murdoch writes:
>> >
>> > With c76695 in the trunk, we now only tilde expand file names starting
>> > with a tilde also when using readline.
>> >
>> > Best
>> > -k
>> >
>> > > On 11/06/2019 4:34 p.m., William Dunlap via R-devel wrote:
>> > >> Note that R treats tildes in file names differently on Windows and
>> > Linux.
>> > >> On Windows, it is only replaced if it it at the beginning of the line
>> > and
>> > >> is followed by a forward or backward slash or end-of-line.  On Linux
>> it
>> > is
>> > >> replaced no matter where it is in the text and ~someUser will be
>> > replaced
>> > >> by someUser's home directory (if 'someUser' is a user with a home
>> > >> directory).
>> >
>> > > That's not quite true:  On Linux the bug is in the code that uses
>> > > libreadline, which you don't have to use.  If you just specify
>> > > "--no-readline" when you start R, it will be fine on Linux, as far as
>> I
>> > > can see.
>> >
>> > > I wouldn't choose that as the default way to run R (it's pretty
>> > > irritating not to have readline support), but it is a workaround for
>> > > this bug.
>> >
>> > > Duncan Murdoch
>> >
>> > >>
>> > >> Hence, if you have a Windows machine that can look at the file
>> system on
>> > >> your Linux machine you can use file.rename on Windows to change the
>> > names.
>> > >> My inclination would be to use a bash script on Linux to change the
>> > names,
>> > >> but if you are not comfortable with bash try the Windows approach.
>> > >>
>> > >> Bill Dunlap
>> > >> TIBCO Software
>> > >> wdunlap tibco.com
>> > >>
>> > >>
>> > >> On Tue, Jun 11, 2019 at 1:13 PM Frank Schwidom <[hidden email]>
>> > wrote:
>> > >>
>> > >>> Hi Gabriel,
>> > >>>
>> > >>> I actually want to make renames over thousands of files. But if I am
>> > not
>> > >>> able to express the source filename of the rename operation I will
>> not
>> > be
>> > >>> able to get the work done. Besides the fact that there are issues I
>> > think
>> > >>> that R is qualified for solving my problem by the method how it can
>> > handle
>> > >>> long vectors of strings, booleans and also lists.
>> > >>>
>> > >>> Kind regards,
>> > >>> Frank
>> > >>>
>> > >>> On 2019-06-11 09:49:17, Gabriel Becker wrote:
>> > >>>> Hi Frank,
>> > >>>> I'm hesitant to be "that guy", but in case no one else has brought
>> > >>> this up
>> > >>>> to you, having files with a tilde in their names (generally but
>> > >>> especially
>> > >>>> on a linux system, where ~ in file names has a very important
>> special
>> > >>>> meaning in some cases, as we know) strikes me as an exceptionally
>> bad
>> > >>>> practice anyway. In light of that, the solution with the smallest
>> > >>> amount
>> > >>>> of pain for you is almost surely to just... not do that. Your
>> > >>> filenames
>> > >>>> will be better for it anyway.
>> > >>>> There is a reason no one has complained about this before, and
>> while I
>> > >>>> haven't run a study or anything, I strongly suspect its that
>> > >>> "everyone"
>> > >>>> else is already on the "no tildes in filenames" bandwagon, so this
>> > >>>> behavior, even if technically a bug, has no ability to cause them
>> > >>>> problems.
>> > >>>> Best,
>> > >>>> ~G
>> > >>>> On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[1]
>> [hidden email]>
>> > >>>> wrote:
>> > >>>>
>> > >>>> Hi,
>> > >>>>
>> > >>>> yes, I have seen this package and it has the same tilde expanding
>> > >>>> problem.
>> > >>>>
>> > >>>> Please excuse me I will cc this answer to r-help and r-devel to
>> > >>> keep the
>> > >>>> discussion running.
>> > >>>>
>> > >>>> Kind regards,
>> > >>>> Frank Schwidom
>> > >>>>
>> > >>>> On 2019-06-11 09:12:36, Gábor Csárdi wrote:
>> > >>>> > Just in case, have you seen the fs package?
>> > >>>> > [2]https://fs.r-lib.org/
>> > >>>> >
>> > >>>> > Gabor
>> > >>>> >
>> > >>>> > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[3]
>> > >>> [hidden email]>
>> > >>>> wrote:
>> > >>>> > >
>> > >>>> > > Hi,
>> > >>>> > >
>> > >>>> > > to get rid of any possible filename modification I started a
>> > >>> little
>> > >>>> project to cover my usecase:
>> > >>>> > >
>> > >>>> > > [4]https://github.com/schwidom/simplefs
>> > >>>> > >
>> > >>>> > > This is my first R package, suggestions and a review are
>> > >>> welcome.
>> > >>>> > >
>> > >>>> > > Thanks in advance
>> > >>>> > > Frank Schwidom
>> > >>>> > >
>> > >>>> > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
>> > >>>> > > >    How can expanding tildes anywhere but the beginning of a
>> > >>> file
>> > >>>> name NOT be
>> > >>>> > > >    considered a bug?
>> > >>>> > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov
>> > >>>> <[1][5][hidden email]> wrote:
>> > >>>> > > >
>> > >>>> > > >      On Wed, 5 Jun 2019 18:07:15 +0200
>> > >>>> > > >      Frank Schwidom <[2][6][hidden email]> wrote:
>> > >>>> > > >
>> > >>>> > > >      > +> path.expand("a ~ b")
>> > >>>> > > >      > [1] "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
>> > >>>> > > >      correctly.
>> > >>>> > > >
>> > >>>> > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName
>> > >>> [3],
>> > >>>> which
>> > >>>> > > >      calls R_ExpandFileName_readline [4], which uses
>> > >>> libreadline
>> > >>>> function
>> > >>>> > > >      tilde_expand [5]. 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,
>> > >>>> > > >      Ivan
>> > >>>> > > >
>> > >>>> > > >      [1]
>> > >>>> > > >
>> > >>>> [3][7]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>> > >>>> > > >
>> > >>>> > > >      [2]
>> > >>>> > > >
>> > >>>> [4][8]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>> > >>>> > > >
>> > >>>> > > >      [3]
>> > >>>> > > >
>> > >>>> [5][9]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>> > >>>> > > >
>> > >>>> > > >      [4]
>> > >>>> > > >
>> > >>>> [6][10]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>> > >>>> > > >
>> > >>>> > > >      [5]
>> > >>>> > > >
>> > >>>> [7][11]
>> > >>>
>> >
>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>> > >>>> > > >
>> > >>>> > > >      ______________________________________________
>> > >>>> > > >      [8][12][hidden email] mailing list -- To
>> > >>> UNSUBSCRIBE
>> > >>>> and more, see
>> > >>>> > > >      [9][13]https://stat.ethz.ch/mailman/listinfo/r-help
>> > >>>> > > >      PLEASE do read the posting guide
>> > >>>> > > >      [10][14]http://www.R-project.org/posting-guide.html
>> > >>>> > > >      and provide commented, minimal, self-contained,
>> > >>> reproducible
>> > >>>> code.
>> > >>>> > > >
>> > >>>> > > > References
>> > >>>> > > >
>> > >>>> > > >    Visible links
>> > >>>> > > >    1. mailto:[15][hidden email]
>> > >>>> > > >    2. mailto:[16][hidden email]
>> > >>>> > > >    3.
>> > >>>> [17]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>> > >>>> > > >    4.
>> > >>>> [18]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>> > >>>> > > >    5.
>> > >>>> [19]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>> > >>>> > > >    6.
>> > >>>> [20]
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>> > >>>> > > >    7.
>> > >>>> [21]
>> > >>>
>> >
>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>> > >>>> > > >    8. mailto:[22][hidden email]
>> > >>>> > > >    9. [23]https://stat.ethz.ch/mailman/listinfo/r-help
>> > >>>> > > >   10. [24]http://www.r-project.org/posting-guide.html
>> > >>>> > >
>> > >>>> > > ______________________________________________
>> > >>>> > > [25][hidden email] mailing list
>> > >>>> > > [26]https://stat.ethz.ch/mailman/listinfo/r-devel
>> > >>>> >
>> > >>>>
>> > >>>> ______________________________________________
>> > >>>> [27][hidden email] mailing list
>> > >>>> [28]https://stat.ethz.ch/mailman/listinfo/r-devel
>> > >>>>
>> > >>>> References
>> > >>>>
>> > >>>> Visible links
>> > >>>> 1. mailto:[hidden email]
>> > >>>> 2. https://fs.r-lib.org/
>> > >>>> 3. mailto:[hidden email]
>> > >>>> 4. https://github.com/schwidom/simplefs
>> > >>>> 5. mailto:[hidden email]
>> > >>>> 6. mailto:[hidden email]
>> > >>>> 7.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>> > >>>> 8.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>> > >>>> 9.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>> > >>>> 10.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>> > >>>> 11.
>> > >>>
>> >
>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>> > >>>> 12. mailto:[hidden email]
>> > >>>> 13. https://stat.ethz.ch/mailman/listinfo/r-help
>> > >>>> 14. http://www.r-project.org/posting-guide.html
>> > >>>> 15. mailto:[hidden email]
>> > >>>> 16. mailto:[hidden email]
>> > >>>> 17.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>> > >>>> 18.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>> > >>>> 19.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>> > >>>> 20.
>> > >>>
>> >
>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>> > >>>> 21.
>> > >>>
>> >
>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>> > >>>> 22. mailto:[hidden email]
>> > >>>> 23. https://stat.ethz.ch/mailman/listinfo/r-help
>> > >>>> 24. http://www.r-project.org/posting-guide.html
>> > >>>> 25. mailto:[hidden email]
>> > >>>> 26. https://stat.ethz.ch/mailman/listinfo/r-devel
>> > >>>> 27. mailto:[hidden email]
>> > >>>> 28. https://stat.ethz.ch/mailman/listinfo/r-devel
>> > >>>
>> > >>> ______________________________________________
>> > >>> [hidden email] mailing list
>> > >>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> > >>>
>> > >>
>> > >> [[alternative HTML version deleted]]
>> > >>
>> > >> ______________________________________________
>> > >> [hidden email] mailing list
>> > >> https://stat.ethz.ch/mailman/listinfo/r-devel
>> > >>
>> >
>> > > ______________________________________________
>> > > [hidden email] mailing list
>> > > https://stat.ethz.ch/mailman/listinfo/r-devel
>> >
>> > ______________________________________________
>> > [hidden email] mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>> >
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Paul McQuesten
Gabriel,

I apologize. I did not mean to flame, merely to point out a typical usage
of tilde that might have escaped the discussion.
As you say, Kurt's fix makes this all moot.
I also apologize for wasting everyone's time with my spam.

On Thu, Jun 13, 2019 at 2:13 AM Gabriel Becker <[hidden email]>
wrote:

> At the risk of looking silly, note that all of this is now largely moot
> anyway (or will be with the next release of R), thanks to Kurt Hornik's
> fixing of the bug in question (which he announced on this thread prior to
> but I read after Paul's).
>
> ~G
>
> On Wed, Jun 12, 2019 at 11:51 PM Gabriel Becker <[hidden email]>
> wrote:
>
>>
>>
>> On Wed, Jun 12, 2019, 5:16 AM Paul McQuesten <[hidden email]> wrote:
>>
>>> @ Gabriel:
>>>
>>> "Avoid tilde in file names":
>>> Not quite.
>>> A tilde *suffix* is commonly used by *nix editors for backup files
>>>
>>> https://unix.stackexchange.com/questions/76189/what-does-the-tilde-mean-at-the-end-of-a-filename
>>
>>
>> I'm aware of that, but that isn't the case that is being discussed, as
>> the example given clearly had a tilde (and spaces) in the middle of the
>> file. Backup files witilde suffix does not trigger the bug being discussed.
>> It's *only* files paths where the tilde is surrounded on both by spaces
>> (or on the right by the end fo the string) that trigger it.
>>
>> > path.expand("a~b")
>>
>> [1] "a~b"
>>
>> > path.expand("a ~ b")
>>
>> [1] "a /Users/gabrielbecker b"
>>
>> > path.expand("myfile.txt~")
>>
>> [1] "myfile.txt~"
>>
>> > path.expand("myfile.txt ~")
>>
>> [1] "myfile.txt /Users/gabrielbecker"
>>
>>
>> All that said I'm really not interested in participating in a flame war
>> over this. I gave my 2 cents as respectfully as I could, so as of now
>> please consider my participation  and interest in this thread closed.
>>
>> Best,
>> ~G
>>
>>
>>
>>>
>>>
>>>
>>> On Wed, Jun 12, 2019 at 2:43 AM Kurt Hornik <[hidden email]>
>>> wrote:
>>>
>>> > >>>>> Duncan Murdoch writes:
>>> >
>>> > With c76695 in the trunk, we now only tilde expand file names starting
>>> > with a tilde also when using readline.
>>> >
>>> > Best
>>> > -k
>>> >
>>> > > On 11/06/2019 4:34 p.m., William Dunlap via R-devel wrote:
>>> > >> Note that R treats tildes in file names differently on Windows and
>>> > Linux.
>>> > >> On Windows, it is only replaced if it it at the beginning of the
>>> line
>>> > and
>>> > >> is followed by a forward or backward slash or end-of-line.  On
>>> Linux it
>>> > is
>>> > >> replaced no matter where it is in the text and ~someUser will be
>>> > replaced
>>> > >> by someUser's home directory (if 'someUser' is a user with a home
>>> > >> directory).
>>> >
>>> > > That's not quite true:  On Linux the bug is in the code that uses
>>> > > libreadline, which you don't have to use.  If you just specify
>>> > > "--no-readline" when you start R, it will be fine on Linux, as far
>>> as I
>>> > > can see.
>>> >
>>> > > I wouldn't choose that as the default way to run R (it's pretty
>>> > > irritating not to have readline support), but it is a workaround for
>>> > > this bug.
>>> >
>>> > > Duncan Murdoch
>>> >
>>> > >>
>>> > >> Hence, if you have a Windows machine that can look at the file
>>> system on
>>> > >> your Linux machine you can use file.rename on Windows to change the
>>> > names.
>>> > >> My inclination would be to use a bash script on Linux to change the
>>> > names,
>>> > >> but if you are not comfortable with bash try the Windows approach.
>>> > >>
>>> > >> Bill Dunlap
>>> > >> TIBCO Software
>>> > >> wdunlap tibco.com
>>> > >>
>>> > >>
>>> > >> On Tue, Jun 11, 2019 at 1:13 PM Frank Schwidom <[hidden email]>
>>> > wrote:
>>> > >>
>>> > >>> Hi Gabriel,
>>> > >>>
>>> > >>> I actually want to make renames over thousands of files. But if I
>>> am
>>> > not
>>> > >>> able to express the source filename of the rename operation I will
>>> not
>>> > be
>>> > >>> able to get the work done. Besides the fact that there are issues I
>>> > think
>>> > >>> that R is qualified for solving my problem by the method how it can
>>> > handle
>>> > >>> long vectors of strings, booleans and also lists.
>>> > >>>
>>> > >>> Kind regards,
>>> > >>> Frank
>>> > >>>
>>> > >>> On 2019-06-11 09:49:17, Gabriel Becker wrote:
>>> > >>>> Hi Frank,
>>> > >>>> I'm hesitant to be "that guy", but in case no one else has brought
>>> > >>> this up
>>> > >>>> to you, having files with a tilde in their names (generally but
>>> > >>> especially
>>> > >>>> on a linux system, where ~ in file names has a very important
>>> special
>>> > >>>> meaning in some cases, as we know) strikes me as an exceptionally
>>> bad
>>> > >>>> practice anyway. In light of that, the solution with the smallest
>>> > >>> amount
>>> > >>>> of pain for you is almost surely to just... not do that. Your
>>> > >>> filenames
>>> > >>>> will be better for it anyway.
>>> > >>>> There is a reason no one has complained about this before, and
>>> while I
>>> > >>>> haven't run a study or anything, I strongly suspect its that
>>> > >>> "everyone"
>>> > >>>> else is already on the "no tildes in filenames" bandwagon, so this
>>> > >>>> behavior, even if technically a bug, has no ability to cause them
>>> > >>>> problems.
>>> > >>>> Best,
>>> > >>>> ~G
>>> > >>>> On Tue, Jun 11, 2019 at 8:25 AM Frank Schwidom <[1]
>>> [hidden email]>
>>> > >>>> wrote:
>>> > >>>>
>>> > >>>> Hi,
>>> > >>>>
>>> > >>>> yes, I have seen this package and it has the same tilde expanding
>>> > >>>> problem.
>>> > >>>>
>>> > >>>> Please excuse me I will cc this answer to r-help and r-devel to
>>> > >>> keep the
>>> > >>>> discussion running.
>>> > >>>>
>>> > >>>> Kind regards,
>>> > >>>> Frank Schwidom
>>> > >>>>
>>> > >>>> On 2019-06-11 09:12:36, Gábor Csárdi wrote:
>>> > >>>> > Just in case, have you seen the fs package?
>>> > >>>> > [2]https://fs.r-lib.org/
>>> > >>>> >
>>> > >>>> > Gabor
>>> > >>>> >
>>> > >>>> > On Tue, Jun 11, 2019 at 7:51 AM Frank Schwidom <[3]
>>> > >>> [hidden email]>
>>> > >>>> wrote:
>>> > >>>> > >
>>> > >>>> > > Hi,
>>> > >>>> > >
>>> > >>>> > > to get rid of any possible filename modification I started a
>>> > >>> little
>>> > >>>> project to cover my usecase:
>>> > >>>> > >
>>> > >>>> > > [4]https://github.com/schwidom/simplefs
>>> > >>>> > >
>>> > >>>> > > This is my first R package, suggestions and a review are
>>> > >>> welcome.
>>> > >>>> > >
>>> > >>>> > > Thanks in advance
>>> > >>>> > > Frank Schwidom
>>> > >>>> > >
>>> > >>>> > > On 2019-06-07 09:04:06, Richard O'Keefe wrote:
>>> > >>>> > > >    How can expanding tildes anywhere but the beginning of a
>>> > >>> file
>>> > >>>> name NOT be
>>> > >>>> > > >    considered a bug?
>>> > >>>> > > >    On Thu, 6 Jun 2019 at 23:04, Ivan Krylov
>>> > >>>> <[1][5][hidden email]> wrote:
>>> > >>>> > > >
>>> > >>>> > > >      On Wed, 5 Jun 2019 18:07:15 +0200
>>> > >>>> > > >      Frank Schwidom <[2][6][hidden email]> wrote:
>>> > >>>> > > >
>>> > >>>> > > >      > +> path.expand("a ~ b")
>>> > >>>> > > >      > [1] "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
>>> > >>>> > > >      correctly.
>>> > >>>> > > >
>>> > >>>> > > >      Calls to path.expand [1] end up [2] in R_ExpandFileName
>>> > >>> [3],
>>> > >>>> which
>>> > >>>> > > >      calls R_ExpandFileName_readline [4], which uses
>>> > >>> libreadline
>>> > >>>> function
>>> > >>>> > > >      tilde_expand [5]. 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,
>>> > >>>> > > >      Ivan
>>> > >>>> > > >
>>> > >>>> > > >      [1]
>>> > >>>> > > >
>>> > >>>> [3][7]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>> > >>>> > > >
>>> > >>>> > > >      [2]
>>> > >>>> > > >
>>> > >>>> [4][8]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>> > >>>> > > >
>>> > >>>> > > >      [3]
>>> > >>>> > > >
>>> > >>>> [5][9]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>> > >>>> > > >
>>> > >>>> > > >      [4]
>>> > >>>> > > >
>>> > >>>> [6][10]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>> > >>>> > > >
>>> > >>>> > > >      [5]
>>> > >>>> > > >
>>> > >>>> [7][11]
>>> > >>>
>>> >
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>> > >>>> > > >
>>> > >>>> > > >      ______________________________________________
>>> > >>>> > > >      [8][12][hidden email] mailing list -- To
>>> > >>> UNSUBSCRIBE
>>> > >>>> and more, see
>>> > >>>> > > >      [9][13]https://stat.ethz.ch/mailman/listinfo/r-help
>>> > >>>> > > >      PLEASE do read the posting guide
>>> > >>>> > > >      [10][14]http://www.R-project.org/posting-guide.html
>>> > >>>> > > >      and provide commented, minimal, self-contained,
>>> > >>> reproducible
>>> > >>>> code.
>>> > >>>> > > >
>>> > >>>> > > > References
>>> > >>>> > > >
>>> > >>>> > > >    Visible links
>>> > >>>> > > >    1. mailto:[15][hidden email]
>>> > >>>> > > >    2. mailto:[16][hidden email]
>>> > >>>> > > >    3.
>>> > >>>> [17]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>> > >>>> > > >    4.
>>> > >>>> [18]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>> > >>>> > > >    5.
>>> > >>>> [19]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>> > >>>> > > >    6.
>>> > >>>> [20]
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>> > >>>> > > >    7.
>>> > >>>> [21]
>>> > >>>
>>> >
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>> > >>>> > > >    8. mailto:[22][hidden email]
>>> > >>>> > > >    9. [23]https://stat.ethz.ch/mailman/listinfo/r-help
>>> > >>>> > > >   10. [24]http://www.r-project.org/posting-guide.html
>>> > >>>> > >
>>> > >>>> > > ______________________________________________
>>> > >>>> > > [25][hidden email] mailing list
>>> > >>>> > > [26]https://stat.ethz.ch/mailman/listinfo/r-devel
>>> > >>>> >
>>> > >>>>
>>> > >>>> ______________________________________________
>>> > >>>> [27][hidden email] mailing list
>>> > >>>> [28]https://stat.ethz.ch/mailman/listinfo/r-devel
>>> > >>>>
>>> > >>>> References
>>> > >>>>
>>> > >>>> Visible links
>>> > >>>> 1. mailto:[hidden email]
>>> > >>>> 2. https://fs.r-lib.org/
>>> > >>>> 3. mailto:[hidden email]
>>> > >>>> 4. https://github.com/schwidom/simplefs
>>> > >>>> 5. mailto:[hidden email]
>>> > >>>> 6. mailto:[hidden email]
>>> > >>>> 7.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>> > >>>> 8.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>> > >>>> 9.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>> > >>>> 10.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>> > >>>> 11.
>>> > >>>
>>> >
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>> > >>>> 12. mailto:[hidden email]
>>> > >>>> 13. https://stat.ethz.ch/mailman/listinfo/r-help
>>> > >>>> 14. http://www.r-project.org/posting-guide.html
>>> > >>>> 15. mailto:[hidden email]
>>> > >>>> 16. mailto:[hidden email]
>>> > >>>> 17.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/names.c#L807
>>> > >>>> 18.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/main/platform.c#L1915
>>> > >>>> 19.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>>> > >>>> 20.
>>> > >>>
>>> >
>>> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e333348b81180a0e2c6f2f/src/unix/sys-std.c#L494
>>> > >>>> 21.
>>> > >>>
>>> >
>>> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
>>> > >>>> 22. mailto:[hidden email]
>>> > >>>> 23. https://stat.ethz.ch/mailman/listinfo/r-help
>>> > >>>> 24. http://www.r-project.org/posting-guide.html
>>> > >>>> 25. mailto:[hidden email]
>>> > >>>> 26. https://stat.ethz.ch/mailman/listinfo/r-devel
>>> > >>>> 27. mailto:[hidden email]
>>> > >>>> 28. https://stat.ethz.ch/mailman/listinfo/r-devel
>>> > >>>
>>> > >>> ______________________________________________
>>> > >>> [hidden email] mailing list
>>> > >>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>> > >>>
>>> > >>
>>> > >> [[alternative HTML version deleted]]
>>> > >>
>>> > >> ______________________________________________
>>> > >> [hidden email] mailing list
>>> > >> https://stat.ethz.ch/mailman/listinfo/r-devel
>>> > >>
>>> >
>>> > > ______________________________________________
>>> > > [hidden email] mailing list
>>> > > https://stat.ethz.ch/mailman/listinfo/r-devel
>>> >
>>> > ______________________________________________
>>> > [hidden email] mailing list
>>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>>> >
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Open a file which name contains a tilde

Serguei Sokol
In reply to this post by Richard O'Keefe-2
On 14/06/2019 14:43, Frank Schwidom wrote:
> Hi John,
>
> First, the unix and linux filesystem allows the use of any nonzero character in its filesystem filenames
Well, even it's not the central point of the discussion let make this
assertion more correct. It depends on file system. E.g. JFS
(https://en.wikipedia.org/wiki/JFS_%28file_system%29) abides to this
rule while very popular ext4 (https://en.wikipedia.org/wiki/Ext4) does
not. In addition to NUL character, the latter forbids '/' as well.

Best,
Serguei.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel