unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 36490@debbugs.gnu.org, erik_hahn@gmx.de
Subject: bug#36490: 26.1; directory-files-recursively breaks when it encounters a directory named "~"
Date: Tue, 09 Jul 2019 20:23:02 +0300	[thread overview]
Message-ID: <83sgrf3yx5.fsf@gnu.org> (raw)
In-Reply-To: <m3zhln5ejm.fsf@gnus.org> (message from Lars Ingebrigtsen on Tue,  09 Jul 2019 19:00:13 +0200)

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 36490@debbugs.gnu.org,  erik_hahn@gmx.de
> Date: Tue, 09 Jul 2019 19:00:13 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Sorry, that's not what I meant to say.  I meant to say how would a
> > Lisp program know whether (expand-file-name "~/") means the home
> > directory or a directory whose name is literally "~"?
> 
> Well, we have documented that in expand-file-name "~/" means the home
> directory, and I have no problems with that.

Documenting a problem doesn't necessarily solve it.  E.g., it is also
documented that you must quote file names with special characters, but
you still raised the objection that the "~" use case makes that "odd".

I'm saying that the "~/" use case is "odd" as well, and for the same
reasons.

> "~/" isn't something you'll ever get from functions like
> directory-files

That's sheer luck, because:

  (file-name-as-directory "~")
    => "~/"

So just running "~" through an innocent API gives you a "magic"
directory name (if you consider "~" not "magic" by itself).  How is
this different from the "odd" use case where one must quote "~" to
avoid its interpretation as the home directory?  Who can guarantee
that some day directory-files-recursively will not want to do
something like the above?  If it does, we will be right back at the
same problem.

I say we should fix this problem in a way that isn't fragile, and
doesn't crucially depend on what the current code does or avoids
doing.

> > Btw, stuff like (expand-file-name "foo/~/") already does what you
> > want, so the problem is only with the leading '~', and can be avoided
> > if we avoid that situation.  IOW, why should this example:
> >
> >   (expand-file-name "~" "/tmp/")
> >      => "/home/larsi"
> >
> > determine how directory-files-recursively behaves?
> 
> expand-file-name's use case is to (basically) concatenate a directory
> name and a file name, but it's used instead of concat because nobody
> wants to care about whether the directory name has a trailing slash or
> not.

Ah, but when the file name begins with a "~", the "concatenation" does
more than what meets the eye.

> That's basically the use case for expand-file-name, and using it has
> avoided a lot of basic concatenation problems over the years (because
> Emacs allows sloppy handling of directory file names in most
> situations).

I think this is a simplification.  It ignores the fact that
expand-file-name interprets ~/, it ignores the fact that it does
arbitrary stuff for "remote" file names, it ignores the fact that on
Windows it prepends the drive letter if there isn't one already, etc.
IOW, expand-file-name is concatenation-like, but it has a few tricks
up its sleeve, and in this case the trick works against us.  We need
to disable that trick to support files and directories whose names
begin with a literal "~".  I see no way around that.





  reply	other threads:[~2019-07-09 17:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 18:07 bug#36490: 26.1; directory-files-recursively breaks when it encounters a directory named "~" Erik Hahn
2019-07-08 20:59 ` Lars Ingebrigtsen
2019-07-08 21:08 ` Lars Ingebrigtsen
2019-07-08 21:30   ` Erik Hahn
2019-07-08 21:56     ` Lars Ingebrigtsen
2019-07-09 15:39     ` Eli Zaretskii
2019-07-09 15:35   ` Eli Zaretskii
2019-07-09 15:50     ` Lars Ingebrigtsen
2019-07-09 16:12       ` Eli Zaretskii
2019-07-09 16:27         ` Lars Ingebrigtsen
2019-07-09 16:44           ` Eli Zaretskii
2019-07-09 16:50             ` Lars Ingebrigtsen
2019-07-09 16:52             ` Eli Zaretskii
2019-07-09 17:00               ` Lars Ingebrigtsen
2019-07-09 17:23                 ` Eli Zaretskii [this message]
2019-07-09 18:16                   ` Michael Albinus
2019-07-10 11:55                   ` Lars Ingebrigtsen
2019-07-10 14:56                     ` Eli Zaretskii
2019-07-11 15:05                       ` Lars Ingebrigtsen
2019-07-09 18:58         ` Basil L. Contovounesios
2019-07-09 19:19           ` Eli Zaretskii
2019-07-09 16:17       ` Andreas Schwab
2019-07-10 12:04 ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83sgrf3yx5.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=36490@debbugs.gnu.org \
    --cc=erik_hahn@gmx.de \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).