|
From: | Jim Porter |
Subject: | 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@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-fooI'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.
[Prev in Thread] | Current Thread | [Next in Thread] |