GNU bug report logs - #40949
26.3; substitute-env-in-file-name: Undefined variables not substituted

Previous Next

Package: emacs;

Reported by: Marcus Harnisch <marcus.harnisch <at> gmx.net>

Date: Tue, 28 Apr 2020 21:01:03 UTC

Severity: normal

Found in version 26.3

Fixed in version 28.1

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

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 40949 in the body.
You can then email your comments to 40949 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-gnu-emacs <at> gnu.org:
bug#40949; Package emacs. (Tue, 28 Apr 2020 21:01:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Marcus Harnisch <marcus.harnisch <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 28 Apr 2020 21:01:03 GMT) Full text and rfc822 format available.

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

From: Marcus Harnisch <marcus.harnisch <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.3; substitute-env-in-file-name: Undefined variables not substituted
Date: Tue, 28 Apr 2020 22:38:14 +0200
With commit ee041f2d07b6ed485dc34c115588f973f046c9d4 the function
`substitute-env-in-file-name' was introduced.

The function substitutes environment variable references in filenames
with the help of `substitute-env-vars'. On systems that are neither
windows-nt nor ms-dos, the optional argument to that function is set to
t with the consequence that references to undefined variables are not
substituted. This is unexpected, IMHO.
Expected behaviour would match that of shell expansion, which
substitutes undefined variables with the empty string.

Cheers,
Marcus





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40949; Package emacs. (Wed, 29 Apr 2020 11:29:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Marcus Harnisch <marcus.harnisch <at> gmx.net>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 40949 <at> debbugs.gnu.org
Subject: Re: bug#40949: 26.3;
 substitute-env-in-file-name: Undefined variables not substituted
Date: Wed, 29 Apr 2020 14:27:35 +0300
> From: Marcus Harnisch <marcus.harnisch <at> gmx.net>
> Date: Tue, 28 Apr 2020 22:38:14 +0200
> 
> With commit ee041f2d07b6ed485dc34c115588f973f046c9d4 the function
> `substitute-env-in-file-name' was introduced.
> 
> The function substitutes environment variable references in filenames
> with the help of `substitute-env-vars'. On systems that are neither
> windows-nt nor ms-dos, the optional argument to that function is set to
> t with the consequence that references to undefined variables are not
> substituted. This is unexpected, IMHO.
> Expected behaviour would match that of shell expansion, which
> substitutes undefined variables with the empty string.

Your report seems to imply that the behavior on MS-Windows is
different, but it isn't: if the variable is undefined, we leave it
unaltered on those systems as well.

Whether Emacs should follow what the shell does is a separate issue.
In this case, since we use this function in substitute-in-file-name,
what it does should serve what substitute-in-file-name was always
doing: it left the $foo constructs unaltered.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40949; Package emacs. (Wed, 29 Apr 2020 12:07:02 GMT) Full text and rfc822 format available.

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

From: Marcus Harnisch <marcus.harnisch <at> gmx.net>
To: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 40949 <at> debbugs.gnu.org
Subject: Re: bug#40949: 26.3; substitute-env-in-file-name: Undefined variables
 not substituted
Date: Wed, 29 Apr 2020 14:06:11 +0200
On 29/04/2020 13.27, Eli Zaretskii wrote:
> Your report seems to imply that the behavior on MS-Windows is
> different, but it isn't: if the variable is undefined, we leave it
> unaltered on those systems as well.
The definition is special-cased for MS-Windows (passes result of getenv 
as opposed to a hardcoded t as optional argument to substitute-env-vars) 
and I am not able to check the relevant behaviour on that platform. 
That's why I pointed it out.
> Whether Emacs should follow what the shell does is a separate issue.
> In this case, since we use this function in substitute-in-file-name,
> what it does should serve what substitute-in-file-name was always
> doing: it left the $foo constructs unaltered.
It is probably moot to argue against long-standing practice, but the 
behaviour could perhaps benefit from a note in docstrings of functions 
that rely on `s-e-i-f-n'. Having used Emacsen and POSIX systems for 
about the same number of decades, I found this difference (Emacs vs 
shell) rather surprising.

Thanks,
Marcus





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40949; Package emacs. (Sun, 13 Jun 2021 12:16:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Marcus Harnisch <marcus.harnisch <at> gmx.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 40949 <at> debbugs.gnu.org
Subject: Re: bug#40949: 26.3; substitute-env-in-file-name: Undefined
 variables not substituted
Date: Sun, 13 Jun 2021 14:15:06 +0200
Marcus Harnisch <marcus.harnisch <at> gmx.net> writes:

>> Whether Emacs should follow what the shell does is a separate issue.
>> In this case, since we use this function in substitute-in-file-name,
>> what it does should serve what substitute-in-file-name was always
>> doing: it left the $foo constructs unaltered.
> It is probably moot to argue against long-standing practice, but the
> behaviour could perhaps benefit from a note in docstrings of functions
> that rely on `s-e-i-f-n'.

Makes sense -- it is somewhat surprising behaviour, so I've now done
this in Emacs 28 for substitute-in-file-name.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 40949 <at> debbugs.gnu.org and Marcus Harnisch <marcus.harnisch <at> gmx.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 13 Jun 2021 12:16:02 GMT) Full text and rfc822 format available.

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

This bug report was last modified 2 years and 287 days ago.

Previous Next


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