GNU bug report logs - #46219
28.0.50; Suboptimal results of `file-relative-name' with mixed-quoted filenames

Previous Next

Package: emacs;

Reported by: Philipp Stephani <p.stephani2 <at> gmail.com>

Date: Sun, 31 Jan 2021 19:27:02 UTC

Severity: minor

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: 46219 <at> debbugs.gnu.org
Subject: bug#46219: 28.0.50; Suboptimal results of `file-relative-name' with mixed-quoted filenames
Date: Sun, 31 Jan 2021 22:08:29 +0200
> From: Philipp Stephani <p.stephani2 <at> gmail.com>
> Date: Sun, 31 Jan 2021 20:26:20 +0100
> 
> $ emacs -Q -batch -eval '(progn (princ (file-relative-name "/:/bin/true" "/bin")) (terpri) (princ (file-relative-name "/bin/true" "/:/bin")) (terpri))'
> ../:/bin/true
> ../../bin/true
> 
> I guess these aren't *technically* wrong, but probably not what's
> intended here.  I'd expect a return value of "true" in both cases.

I think your expectations are misplaced.  The doc string says:

  This function returns a relative file name that is equivalent to FILENAME
  when used with that default directory as the default.

So you should use

   (file-relative-name "/:/bin/true" "/:/bin")

A useful rule of thumb to remember is that this function treats its
argument as a literal string, it doesn't apply any file-name
semantics.




This bug report was last modified 4 years and 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.