GNU bug report logs - #2062
PATH can contain non-expanded variables

Previous Next

Packages: w32, emacs;

Reported by: Juanma Barranquero <lekktu <at> gmail.com>

Date: Mon, 26 Jan 2009 13:10:04 UTC

Severity: normal

Tags: notabug

Found in version 23.0.60

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 2062 in the body.
You can then email your comments to 2062 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>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Mon, 26 Jan 2009 13:10:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juanma Barranquero <lekktu <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Mon, 26 Jan 2009 13:10:04 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Emacs Bug Tracker <submit <at> debbugs.gnu.org>
Subject: PATH can contain non-expanded variables
Date: Mon, 26 Jan 2009 14:00:15 +0100
Package: emacs,w32
Version: 23.0.60

It is possible for PATH (or other path-like variables, like EMACSPATH
and EMACSLOADPATH) to contain unexpanded variables:

ELISP> exec-path
("c:/emacs/bin" "%MYTEST%" "C:/WINDOWS/system32" "C:/WINDOWS"
"C:/WINDOWS/system32/Wbem" "c:/emacs/trunk/bin")

for example, if the user has set
"HKLM\Microsoft\Windows\CurrentVersion\App Paths\emacs.exe\Path" as a
REG_EXPAND_SZ.

These variables should be expanded, but currently
emacs.c:decode_env_path does not. The following patch fixes it.

Comments?

    Juanma


Index: emacs.c
===================================================================
RCS file: /sources/emacs/emacs/src/emacs.c,v
retrieving revision 1.461
diff -u -2 -r1.461 emacs.c
--- emacs.c	23 Jan 2009 14:53:11 -0000	1.461
+++ emacs.c	26 Jan 2009 12:48:49 -0000
@@ -2467,6 +2467,12 @@
   if (path)
     {
+#ifdef WINDOWSNT
+      DWORD required = ExpandEnvironmentStrings (path, NULL, 0);
+      p = (char *) alloca (required);
+      ExpandEnvironmentStrings (path, p, required);
+#else
       p = alloca (strlen (path) + 1);
       strcpy (p, path);
+#endif
       path = p;




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Mon, 26 Jan 2009 22:10:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Mon, 26 Jan 2009 22:10:04 GMT) Full text and rfc822 format available.

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

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Juanma Barranquero <lekktu <at> gmail.com>, 2062 <at> debbugs.gnu.org
Cc: Emacs Bug Tracker <submit <at> debbugs.gnu.org>
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Mon, 26 Jan 2009 23:01:05 +0100
On Mon, Jan 26, 2009 at 2:00 PM, Juanma Barranquero <lekktu <at> gmail.com> wrote:
> Package: emacs,w32
> Version: 23.0.60
>
> It is possible for PATH (or other path-like variables, like EMACSPATH
> and EMACSLOADPATH) to contain unexpanded variables:
>
> ELISP> exec-path
> ("c:/emacs/bin" "%MYTEST%" "C:/WINDOWS/system32" "C:/WINDOWS"
> "C:/WINDOWS/system32/Wbem" "c:/emacs/trunk/bin")
>
> for example, if the user has set
> "HKLM\Microsoft\Windows\CurrentVersion\App Paths\emacs.exe\Path" as a
> REG_EXPAND_SZ.
>
> These variables should be expanded, but currently
> emacs.c:decode_env_path does not. The following patch fixes it.
>
> Comments?

Nice. Thanks.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Mon, 26 Jan 2009 22:10:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Mon, 26 Jan 2009 22:10:05 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 02:05:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jason Rumney <jasonr <at> f2s.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 02:05:03 GMT) Full text and rfc822 format available.

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

From: Jason Rumney <jasonr <at> f2s.com>
To: Juanma Barranquero <lekktu <at> gmail.com>, 2062 <at> debbugs.gnu.org
Cc: Emacs Bug Tracker <submit <at> debbugs.gnu.org>
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 09:56:59 +0800
Juanma Barranquero wrote:
> Index: emacs.c
> ===================================================================
> RCS file: /sources/emacs/emacs/src/emacs.c,v
> retrieving revision 1.461
> diff -u -2 -r1.461 emacs.c
> --- emacs.c	23 Jan 2009 14:53:11 -0000	1.461
> +++ emacs.c	26 Jan 2009 12:48:49 -0000
> @@ -2467,6 +2467,12 @@
>    if (path)
>      {
> +#ifdef WINDOWSNT
> +      DWORD required = ExpandEnvironmentStrings (path, NULL, 0);
> +      p = (char *) alloca (required);
> +      ExpandEnvironmentStrings (path, p, required);
> +#else
>        p = alloca (strlen (path) + 1);
>        strcpy (p, path);
> +#endif
>        path = p;
>   

The right place to do this expansion is where the variable is read from 
the registry, and only when the type is REG_EXPAND_SZ.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 02:05:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jason Rumney <jasonr <at> f2s.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 02:05:05 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 08:40:04 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>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 08:40:04 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Jason Rumney <jasonr <at> f2s.com>
Cc: 2062 <at> debbugs.gnu.org
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 09:34:26 +0100
On Tue, Jan 27, 2009 at 02:56, Jason Rumney <jasonr <at> f2s.com> wrote:

> The right place to do this expansion is where the variable is read from the
> registry, and only when the type is REG_EXPAND_SZ.

The problem is, we don't read
"HKLM\Software\Microsoft\Windows\CurrentVersion\App
Paths\emacs.exe\Path", we find the PATH made for us and it contains
unexpanded variables.

My patch modifies decode_env_path, because it is used for PATH-like
variables, not generic environment variables. How likely is that such
a PATH-like variable contains a string like %VARIABLENAME%, meaning a
literal "%VARIABLENAME%" directory or filename (or part of it)? That's
a hypothetical problem, while my path containing such a variable is a
fact.

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 09:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jason Rumney <jasonr <at> f2s.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 09:30:02 GMT) Full text and rfc822 format available.

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

From: Jason Rumney <jasonr <at> f2s.com>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 2062 <at> debbugs.gnu.org
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 17:24:07 +0800
Juanma Barranquero wrote:
> On Tue, Jan 27, 2009 at 02:56, Jason Rumney <jasonr <at> f2s.com> wrote:
>
>   
>> The right place to do this expansion is where the variable is read from the
>> registry, and only when the type is REG_EXPAND_SZ.
>>     
>
> The problem is, we don't read
> "HKLM\Software\Microsoft\Windows\CurrentVersion\App
> Paths\emacs.exe\Path", we find the PATH made for us and it contains
> unexpanded variables.
>   

If the system does not handle REG_EXPAND_SZ in the App Paths registry 
values, then the bug is with whatever incorrectly used that type when 
setting the registry value.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 10:35:02 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>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 10:35:03 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Jason Rumney <jasonr <at> f2s.com>
Cc: 2062 <at> debbugs.gnu.org
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 11:25:20 +0100
On Tue, Jan 27, 2009 at 10:24, Jason Rumney <jasonr <at> f2s.com> wrote:

> If the system does not handle REG_EXPAND_SZ in the App Paths registry
> values, then the bug is with whatever incorrectly used that type when
> setting the registry value.

I'd say that Microsoft is of two minds about it, judging by the
entries for msimn.exe (Outlook Express), pbrush.exe (mspaint) and a
few others, that do use REG_EXPAND_SZ.

That said, ExpandEnvironmentStrings is not *specifically* for
REG_EXPAND_SZ registry entries; it is generally useful for cases such
as this one.

So we can either:

  a) consider it as a bug outsize Emacs, and do nothing, or

  b) decide that a variable-like string of the form %VARIABLE% in a
PATH-like value is much, much likely to be that, an unexpanded env
var, than part of a file or directory name, and so expand it.

I'm obviously in camp b), and would like to commit this patch. If
you're strongly on camp a, though, I'll close this bug as notabug +
wontfix.

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 13:40:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jason Rumney <jasonr <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 13:40:03 GMT) Full text and rfc822 format available.

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

From: Jason Rumney <jasonr <at> gnu.org>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 2062 <at> debbugs.gnu.org
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 21:29:55 +0800
Juanma Barranquero wrote:
>   b) decide that a variable-like string of the form %VARIABLE% in a
> PATH-like value is much, much likely to be that, an unexpanded env
> var, than part of a file or directory name, and so expand it.
>   

If we decide b, then why would we only decide that for Windows (syntax 
excepted)?





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 14:50:04 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>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 14:50:04 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Jason Rumney <jasonr <at> gnu.org>
Cc: 2062 <at> debbugs.gnu.org
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 15:42:25 +0100
On Tue, Jan 27, 2009 at 14:29, Jason Rumney <jasonr <at> gnu.org> wrote:

> If we decide b, then why would we only decide that for Windows (syntax
> excepted)?

No particular reason, except that REG_EXPAND_SZ exists, and so, having
variables in PATH is not uncommon on Windows, while it is perhaps
uncommon in other OSes. But that's no reason not to generalize it, if
deemed useful, of course.

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 19:10:04 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>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 19:10:05 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Jason Rumney <jasonr <at> gnu.org>
Cc: 2062 <at> debbugs.gnu.org, Juanma Barranquero <lekktu <at> gmail.com>
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 14:02:11 -0500
>> b) decide that a variable-like string of the form %VARIABLE% in a
>> PATH-like value is much, much likely to be that, an unexpanded env
>> var, than part of a file or directory name, and so expand it.
> If we decide b, then why would we only decide that for Windows (syntax
> excepted)?

It looks like a situation where the variable expansion is expected to be
done by the application under w32 (just like file globbing is not done
by the shell there either), contrary to POSIX.
So it's definitely not needed in GNU/Linux, and probably not in Mac OS
X either.  I cannot judge whether Juanma's patch is doing the right
thing, or is working around some bug/misfeature elsewhere, or is really
doing something wrong (it looks like the second option, tho).


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 19:40:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 19:40:03 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juanma Barranquero <lekktu <at> gmail.com>, 2062 <at> debbugs.gnu.org
Cc: jasonr <at> f2s.com
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 21:30:41 +0200
> From: Juanma Barranquero <lekktu <at> gmail.com>
> Cc: 2062 <at> emacsbugs.donarmstrong.com
> 
> On Tue, Jan 27, 2009 at 10:24, Jason Rumney <jasonr <at> f2s.com> wrote:
> 
> > If the system does not handle REG_EXPAND_SZ in the App Paths registry
> > values, then the bug is with whatever incorrectly used that type when
> > setting the registry value.
> 
> I'd say that Microsoft is of two minds about it, judging by the
> entries for msimn.exe (Outlook Express), pbrush.exe (mspaint) and a
> few others, that do use REG_EXPAND_SZ.
> 
> That said, ExpandEnvironmentStrings is not *specifically* for
> REG_EXPAND_SZ registry entries; it is generally useful for cases such
> as this one.

What was the use-case that caused Path to include unexpanded
environment variables in your case?




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 20:05:05 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>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 20:05:05 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 2062 <at> debbugs.gnu.org, jasonr <at> f2s.com
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 20:55:09 +0100
On Tue, Jan 27, 2009 at 20:30, Eli Zaretskii <eliz <at> gnu.org> wrote:

> What was the use-case that caused Path to include unexpanded
> environment variables in your case?

In *my* case, I run several instances of Emacs, and I put different
binaries (image libraries, etc.) in several directories, pointed to by
one environment variable. I always start Emacs from the command line,
and I set the environment variable according to which Emacs I want to
run and what additional binaries to use. I have the App Path set to
C:\emacs\%myvar%\bin, where %myvar% points to the relevant dir.

But my use case is not important: there are many ways to do what I do,
and I'm not even claiming mine is optimal, or close to it.

If I want to fix that (or work around it, if it is a Windows bug) is
because certainly there's nothing precluding the user from setting a
REG_EXPAND_SZ for PATH, or EMACSPATH or EMACSLOADPATH, and there seems
to be no downside to this change, unless we deem
C:\this\is%myweird%path\to\file likely.

But this does not merit too long a discussion IMO. Either you (all)
think it's useful, or hackish. Your call.

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Tue, 27 Jan 2009 20:10:04 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>, owner <at> emacsbugs.donarmstrong.com. (Tue, 27 Jan 2009 20:10:04 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Jason Rumney <jasonr <at> gnu.org>, 2062 <at> debbugs.gnu.org
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Tue, 27 Jan 2009 21:00:47 +0100
On Tue, Jan 27, 2009 at 20:02, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> I cannot judge whether Juanma's patch is doing the right
> thing, or is working around some bug/misfeature elsewhere, or is really
> doing something wrong (it looks like the second option, tho).

I think my patch works around a underspecified part of PATH
processing. In my quite-informal tests, it seems like App Path
expansion is done, or not done, differently for different command
shells, and also depends on whether you run the program from CMD or
the Windows Explorer shell.

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Wed, 28 Jan 2009 04:20:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Wed, 28 Jan 2009 04:20:03 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 2062 <at> debbugs.gnu.org, jasonr <at> f2s.com
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Wed, 28 Jan 2009 06:12:37 +0200
> Date: Tue, 27 Jan 2009 20:55:09 +0100
> From: Juanma Barranquero <lekktu <at> gmail.com>
> Cc: 2062 <at> emacsbugs.donarmstrong.com, jasonr <at> f2s.com
> 
> But this does not merit too long a discussion IMO. Either you (all)
> think it's useful, or hackish. Your call.

I was trying to understand how come a variable is stored in the
Registry with incorrect REG_EXPAND_SZ, and how often that happens.  Is
that true that in your case it is simply a user mistake?




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

Acknowledgement sent to Jason Rumney <jasonr <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Wed, 28 Jan 2009 08:45:03 GMT) Full text and rfc822 format available.

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

From: Jason Rumney <jasonr <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 2062 <at> debbugs.gnu.org, Juanma Barranquero <lekktu <at> gmail.com>
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Wed, 28 Jan 2009 16:39:10 +0800
Stefan Monnier wrote:
> It looks like a situation where the variable expansion is expected to be
> done by the application under w32 (just like file globbing is not done
> by the shell there either), contrary to POSIX.
>   
Environment variables are expanded in PATH when set as an environment 
variable on Windows. Only when using this undocumented registry entry to 
set an application specific path does the expansion apparently not happen.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Wed, 28 Jan 2009 08:50: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>, owner <at> emacsbugs.donarmstrong.com. (Wed, 28 Jan 2009 08:50:03 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 2062 <at> debbugs.gnu.org, jasonr <at> f2s.com
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Wed, 28 Jan 2009 09:36:55 +0100
On Wed, Jan 28, 2009 at 05:12, Eli Zaretskii <eliz <at> gnu.org> wrote:

> I was trying to understand how come a variable is stored in the
> Registry with incorrect REG_EXPAND_SZ, and how often that happens.  Is
> that true that in your case it is simply a user mistake?

Of course not. It was done on purpose, if that's what you're asking.
But I don't see anything that suggests that REG_EXPAND_SZ is not valid
for App Path entries. In fact, Microsoft adds such entries, and
perusing the MSDN seems to indicate that they are indeed valid.

Not only that: if I start Emacs from a desktop shortcut (and, thus,
through ShellExecute), App Paths is correctly expanded.

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Wed, 28 Jan 2009 08:55:06 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>, owner <at> emacsbugs.donarmstrong.com. (Wed, 28 Jan 2009 08:55:06 GMT) Full text and rfc822 format available.

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

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Jason Rumney <jasonr <at> gnu.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 2062 <at> debbugs.gnu.org
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Wed, 28 Jan 2009 09:45:56 +0100
On Wed, Jan 28, 2009 at 09:39, Jason Rumney <jasonr <at> gnu.org> wrote:

> Only when using this undocumented registry entry [...]

Underdocumented, or badly documented, perhaps. Undocumented is not:

http://msdn.microsoft.com/en-us/library/cc144150(VS.85).aspx

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2062; Package emacs,w32. (Wed, 28 Jan 2009 14:30:03 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>, owner <at> emacsbugs.donarmstrong.com. (Wed, 28 Jan 2009 14:30:03 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 2062 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
        jasonr <at> f2s.com
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Wed, 28 Jan 2009 09:24:43 -0500
> Not only that: if I start Emacs from a desktop shortcut (and, thus,
> through ShellExecute), App Paths is correctly expanded.

So your patch works around a bug in some other place which fails to
expand PATH.


        Stefan






Reply sent to Juanma Barranquero <lekktu <at> gmail.com>:
You have taken responsibility. (Wed, 28 Jan 2009 15:15:03 GMT) Full text and rfc822 format available.

Notification sent to Juanma Barranquero <lekktu <at> gmail.com>:
bug acknowledged by developer. (Wed, 28 Jan 2009 15:15:03 GMT) Full text and rfc822 format available.

Message #100 received at 2062-close <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 2062-close <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
        jasonr <at> f2s.com
Subject: Re: bug#2062: PATH can contain non-expanded variables
Date: Wed, 28 Jan 2009 16:07:03 +0100
On Wed, Jan 28, 2009 at 15:24, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> So your patch works around a bug in some other place which fails to
> expand PATH.

Not only you're right, but I know which program is causing the problem. Thanks!

According to MSDN KB 837633 (and other sources):

  Windows XP adds the path value, if it exists, to the PATH
environment variable,
  if you use the ShellExecute() function to start your program.

So, correctly, Windows Explorer uses App Paths, and CMD.EXE does not
(I've checked it).

The problem is with TCC (formerly 4NT), a proprietary command shell I
use. I had mistakenly assumed that TCC worked like CMD (or, in fact, I
did the reverse: because TCC adds App Paths to PATH, I assumed that
CMD also did it).

But it is not: apparently, TCC is adding App Paths to PATH (which is
either a bug or a feature, depending of one's POV), but it's not
taking into account that the App Paths entry can be REG_EXPAND_SZ (and
that's definitely a bug).

I'll report it to them.

    Juanma




Tags added: notabug Request was from Juanma Barranquero <lekktu <at> gmail.com> to control <at> emacsbugs.donarmstrong.com. (Wed, 28 Jan 2009 15:45:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Thu, 26 Feb 2009 15:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 16 years and 174 days ago.

Previous Next


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