From: Eli Zaretskii <eliz@gnu.org>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: 46219@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 [thread overview]
Message-ID: <83h7mw7ttu.fsf@gnu.org> (raw)
In-Reply-To: <wvr4im7csyar.fsf@gmail.com> (message from Philipp Stephani on Sun, 31 Jan 2021 20:26:20 +0100)
> From: Philipp Stephani <p.stephani2@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.
next prev parent reply other threads:[~2021-01-31 20:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-31 19:26 bug#46219: 28.0.50; Suboptimal results of `file-relative-name' with mixed-quoted filenames Philipp Stephani
2021-01-31 20:08 ` Eli Zaretskii [this message]
2021-02-01 9:10 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83h7mw7ttu.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=46219@debbugs.gnu.org \
--cc=p.stephani2@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.