GNU bug report logs - #12689
24.2; Eshell ${cmd} substitution

Previous Next

Package: emacs;

Reported by: Aidan Gauland <aidalgol <at> no8wireless.co.nz>

Date: Sat, 20 Oct 2012 08:09:02 UTC

Severity: normal

Found in version 24.2

Full log


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

From: Jim Porter <jporterbugs <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>,
 Aidan Gauland <aidalgol <at> no8wireless.co.nz>
Cc: 12689 <at> debbugs.gnu.org
Subject: Re: bug#12689: 24.2; Eshell ${cmd} substitution
Date: Wed, 9 Feb 2022 11:01:05 -0800
On 2/9/2022 1:12 AM, Lars Ingebrigtsen wrote:
> Aidan Gauland <aidalgol <at> no8wireless.co.nz> writes:
> 
>> In Eshell, ${cmd} expands to nil.
>> e.g.
>> $ echo ${/bin/echo -e "foo\nbar"}
>> $
>> Note the absence of any output from `echo'.
>>
>> $ echo ${/bin/echo -e "foo\nbar"}-foo
>> nil-foo
>> n$
> 
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
> 
> Looks like this has been fixed in the decade since it was reported:
> 
> / $ echo ${/bin/echo -e "foo\nbar"}
> ("foo" "bar")
> / $ echo ${/bin/echo -e "foo\nbar"}-foo
> ("foo" "bar")-foo
> 
> So I'm therefore closing this bug report.  If there's more to be done
> here, please respond to the debbugs address and we'll reopen.

I think the fix is from bug#30725. I'd meant to post an update to this 
bug as well, but I haven't had a chance to investigate the other half of 
this bug yet. Specifically, I think there's at least an argument that 
the result *should* look like this:

  / $ echo ${/bin/echo -e "foo\nbar"}
  foo
  bar
  / $ echo ${/bin/echo -e "foo\nbar"}-foo
  foo
  bar-foo

I'm still not 100% sure what's going on here, but I think the ${} 
subcommand evaluation splits the output on "\n" to make a list (which 
seems reasonable to me). However, when it gets converted back to a 
string (either to print directly, as in the first case, or to 
concatenate, as in the second case), it ends up looking like '("foo" 
"bar")'. You can see a little more clearly how these cases are different 
by calling `message' instead of `echo':

  ~ $ message %S ${*echo -e "foo\nbar"}
  ("foo" "bar")
  ~ $ message %S ${*echo -e "foo\nbar"}-foo
  "(\"foo\" \"bar\")-foo"

So the result of "${...}" is a list, and the result of "${...}-foo" is a 
string.

I think it would make sense to do something to improve how "foo\nbar" 
gets round-tripped here so that the result is more consistent with 
regular shells. I have a couple of ideas, but I'll need a bit of time to 
tinker with things to see how they work, and to find a solution that 
keeps incompatible changes to a minimum.




This bug report was last modified 3 years and 42 days ago.

Previous Next


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