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

2019-06-11 Thread Frank Schwidom
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  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]krylov.r...@gmail.com> 
> > > wrote:
> > >
> > >  On Wed, 5 Jun 2019 18:07:15 +0200
> > >  Frank Schwidom <[2]schwi...@gmx.net> 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/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
> > >
> > >  [2]
> > >  
> > > [4]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/platform.c#L1915
> > >
> > >  [3]
> > >  
> > > [5]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > >
> > >  [4]
> > >  
> > > [6]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > >
> > >  [5]
> > >  
> > > [7]https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > >
> > >  __
> > >  [8]r-h...@r-project.org 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:krylov.r...@gmail.com
> > >2. mailto:schwi...@gmx.net
> > >3. 
> > > https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
> > >4. 
> > > https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/platform.c#L1915
> > >5. 
> > > https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > >6. 
> > > https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > >7. 
> > > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > >8. mailto:r-h...@r-project.org
> > >9. https://stat.ethz.ch/mailman/listinfo/r-help
> > >   10. http://www.r-project.org/posting-guide.html
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


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

2019-06-11 Thread Gabriel Becker
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  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  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]
> krylov.r...@gmail.com> wrote:
> > > >
> > > >  On Wed, 5 Jun 2019 18:07:15 +0200
> > > >  Frank Schwidom <[2]schwi...@gmx.net> 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/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
> > > >
> > > >  [2]
> > > >  [4]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/platform.c#L1915
> > > >
> > > >  [3]
> > > >  [5]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > > >
> > > >  [4]
> > > >  [6]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > > >
> > > >  [5]
> > > >  [7]
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > > >
> > > >  __
> > > >  [8]r-h...@r-project.org 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:krylov.r...@gmail.com
> > > >2. mailto:schwi...@gmx.net
> > > >3.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
> > > >4.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/platform.c#L1915
> > > >5.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > > >6.
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > > >7.
> https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > > >8. mailto:r-h...@r-project.org
> > > >9. https://stat.ethz.ch/mailman/listinfo/r-help
> > > >   10. http://www.r-project.org/posting-guide.html
> > >
> > > __
> > > R-devel@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo

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

2019-06-11 Thread 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 
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  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 
> 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]
> > krylov.r...@gmail.com> wrote:
> > > > >
> > > > >  On Wed, 5 Jun 2019 18:07:15 +0200
> > > > >  Frank Schwidom <[2]schwi...@gmx.net> 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/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
> > > > >
> > > > >  [2]
> > > > >  [4]
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/platform.c#L1915
> > > > >
> > > > >  [3]
> > > > >  [5]
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-unix.c#L147
> > > > >
> > > > >  [4]
> > > > >  [6]
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-std.c#L494
> > > > >
> > > > >  [5]
> > > > >  [7]
> > https://git.savannah.gnu.org/cgit/readline.git/tree/tilde.c?h=devel#n187
> > > > >
> > > > >  __
> > > > >  [8]r-h...@r-project.org 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:krylov.r...@gmail.com
> > > > >2. mailto:schwi...@gmx.net
> > > > >3.
> >
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
> > >

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

2019-06-11 Thread Frank Schwidom
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]schwi...@gmx.net>
>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]schwi...@gmx.net>
>  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]krylov.r...@gmail.com> wrote:
>  > > >
>  > > >      On Wed, 5 Jun 2019 18:07:15 +0200
>  > > >      Frank Schwidom <[2][6]schwi...@gmx.net> 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/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
>  > > >
>  > > >      [2]
>  > > >     
>  
> [4][8]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/platform.c#L1915
>  > > >
>  > > >      [3]
>  > > >     
>  
> [5][9]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/unix/sys-unix.c#L147
>  > > >
>  > > >      [4]
>  > > >     
>  
> [6][10]https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/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]r-h...@r-project.org 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 

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

2019-06-11 Thread William Dunlap via R-devel
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  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]schwi...@gmx.net>
> >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]
> schwi...@gmx.net>
> >  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]krylov.r...@gmail.com> wrote:
> >  > > >
> >  > > >  On Wed, 5 Jun 2019 18:07:15 +0200
> >  > > >  Frank Schwidom <[2][6]schwi...@gmx.net> 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/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807
> >  > > >
> >  > > >  [2]
> >  > > >
> >  [4][8]
> https://github.com/wch/r-source/blob/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/platform.c#L1915
> >  > > >
> >  > 

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

2019-06-11 Thread Duncan Murdoch

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  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]schwi...@gmx.net>
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]

schwi...@gmx.net>

  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]krylov.r...@gmail.com> wrote:
  > > >
  > > >  On Wed, 5 Jun 2019 18:07:15 +0200
  > > >  Frank Schwidom <[2][6]schwi...@gmx.net> 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/12d1d2d232d84aa355e48b81180a0e2c6f2f/src/main/names.c#L807

  > > >
  > > >  [2]
  > > >