GNU bug report logs - #4823
w32 paths `substitute-in-file-name' fails when environmental variable is set for \\ style paths:

Previous Next

Package: emacs;

Reported by: MON KEY <monkey <at> sandpframing.com>

Date: Wed, 28 Oct 2009 20:25:05 UTC

Severity: normal

Done: Juanma Barranquero <lekktu <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4823 in the body.
You can then email your comments to 4823 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4823; Package emacs. (Wed, 28 Oct 2009 20:25:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to MON KEY <monkey <at> sandpframing.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 28 Oct 2009 20:25:06 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: bug-gnu-emacs <at> gnu.org
Subject: w32 paths `substitute-in-file-name' fails when environmental variable 
	is set for \\ style paths:
Date: Wed, 28 Oct 2009 16:19:44 -0400
w32 paths `substitute-in-file-name' fails when environmental variable
is set for \\ style paths:

;; :SITUATION-1 w/out trailing `\\'
(setenv "HOME2" "C:\\home\\me")
(getenv "HOME2")
;=> "C:\\home\\me"
(substitute-in-file-name "$HOME2\\.emacs")
;=> "C:\\home\\me/emacs"
(substitute-in-file-name "$HOME2/.emacs")
;=>"C:\\home\\me/.emacs"
(substitute-in-file-name "$HOME2.emacs")
;=> "C:\\home\\me.emacs"

;; :SITUATION-2 with trailing `\\'
(setenv "HOME2" "C:\\home\\me\\")
(getenv "HOME2")
;=> "C:\\home\\me\\"
(substitute-in-file-name "$HOME2\\.emacs")
;=> "/.emacs"
(substitute-in-file-name "$HOME2\.emacs")
;=> "C:\\home\\me\\.emacs"
(substitute-in-file-name "$HOME2//.emacs")
;=> "/.emacs"
(substitute-in-file-name "$HOME2.emacs")
;=> "C:\\home\\me\\.emacs"

;; ON FOLLOWING SYSTEM:
GNU Emacs 23.1.50.1 (i386-mingw-nt5.1.2600)
 of 2009-06-30 on LENNART-69DE564 (patched)




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4823; Package emacs. (Wed, 28 Oct 2009 21:45:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juanma Barranquero <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 28 Oct 2009 21:45:03 GMT) Full text and rfc822 format available.

Message #10 received at 4823 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 4823 <at> debbugs.gnu.org
Subject: Re: bug#4823: w32 paths `substitute-in-file-name' fails when 
	environmental variable is set for \\ style paths:
Date: Wed, 28 Oct 2009 22:38:34 +0100
On Wed, Oct 28, 2009 at 21:19, MON KEY <monkey <at> sandpframing.com> wrote:

> ;; :SITUATION-1 w/out trailing `\\'

> (substitute-in-file-name "$HOME2\\.emacs")
> ;=> "C:\\home\\me/emacs"

I get "C:\\home\\me/.emacs", which seems correct.

> (substitute-in-file-name "$HOME2/.emacs")
> ;=>"C:\\home\\me/.emacs"
> (substitute-in-file-name "$HOME2.emacs")
> ;=> "C:\\home\\me.emacs"

These seem correct to me.

> ;; :SITUATION-2 with trailing `\\'

> (substitute-in-file-name "$HOME2\\.emacs")
> ;=> "/.emacs"

$HOME2\\.emacs ==> "C:\\home\\me\\\\.emacs" ==> C:\home\me\\.emacs

According to the docstring of `substitute-in-file-name':

  If `//' appears, everything up to and including the first of
  those `/' is discarded.

and \\ (quoted to \\\\) is equivalent to // in w32 filenames (at least
for Emacs).

> (substitute-in-file-name "$HOME2\.emacs")
> ;=> "C:\\home\\me\\.emacs"

$HOME2\.emacs ==> "C:\\home\\me\\\.emacs" ==> C:\home\me\.emacs

so this is correct (remember that "\." == ".").

> (substitute-in-file-name "$HOME2//.emacs")
> ;=> "/.emacs"

This is similar to the \\\\ case above:

$HOME2//.emacs ==> "C:\\home\\me\\//.emacs" ==> C:\home\me\//.emacs

which could arguably be //.emacs, but that does not seem very useful.

> (substitute-in-file-name "$HOME2.emacs")
> ;=> "C:\\home\\me\\.emacs"

That seems correct.

What where you expecting in each case?

    Juanma



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4823; Package emacs. (Thu, 29 Oct 2009 00:50:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 29 Oct 2009 00:50:05 GMT) Full text and rfc822 format available.

Message #15 received at 4823 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 4823 <at> debbugs.gnu.org, MON KEY <monkey <at> sandpframing.com>
Subject: Re: bug#4823: w32 paths `substitute-in-file-name' fails when environmental variable is set for \\ style paths:
Date: Wed, 28 Oct 2009 20:43:33 -0400
> According to the docstring of `substitute-in-file-name':

>   If `//' appears, everything up to and including the first of
>   those `/' is discarded.

Admittedly, I think substitute-in-file-name implements this feature
incorrectly, because the double-slash handling should be done before
envvar expansion (envvars ceom from outside Emacs usually, so they
generally rely on the convention that /foo///bar is equivalent to
/foo/bar rather than to /bar).

OTOH if an envvar holds "http://foo/bar", then we'd want to use
url-handler-mode's implementation of substitute-in-file-name, which
would argue for doing expansion early.  It's probably tricky to get it
to do the right thing in "all" cases.


        Stefan



Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#4823; Package emacs. (Sat, 02 Jul 2011 01:41:01 GMT) Full text and rfc822 format available.

Message #18 received at 4823 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4823 <at> debbugs.gnu.org, MON KEY <monkey <at> sandpframing.com>
Subject: Re: bug#4823: w32 paths `substitute-in-file-name' fails when
	environmental variable is set for \\ style paths:
Date: Sat, 2 Jul 2011 03:39:54 +0200
I'm closing this one because the original reported behavior is not a
bug, and there's nothing else to do.

    Juanma




Reply sent to Juanma Barranquero <lekktu <at> gmail.com>:
You have taken responsibility. (Sat, 02 Jul 2011 01:49:02 GMT) Full text and rfc822 format available.

Notification sent to MON KEY <monkey <at> sandpframing.com>:
bug acknowledged by developer. (Sat, 02 Jul 2011 01:49:02 GMT) Full text and rfc822 format available.

Message #23 received at 4823-done <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: 4823-done <at> debbugs.gnu.org
Subject: Re: bug#4823: w32 paths `substitute-in-file-name' fails when
	environmental variable is set for \\ style paths:
Date: Sat, 2 Jul 2011 03:47:18 +0200
> I'm closing this one

No, *now* I'm closing it...

    Juanma




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 30 Jul 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 322 days ago.

Previous Next


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