GNU bug report logs -
#59612
29.0.50; Eshell: The behavior of conditionals depends on whitespace
Previous Next
Full log
Message #17 received at 59612 <at> debbugs.gnu.org (full text, mbox):
On 11/26/2022 7:52 AM, Milan Zimmermann wrote:
> # Result:
> # "It is 3"
> # "It is NOT 3"
> #
>
> if { = 3 3 } {
> echo "It is 3"
> }
> {
> echo "It is NOT 3"
> }
According to Eshell's logic, I think this is correct (though
inconvenient). Because Eshell treats a newline as the end of a command
whenever possible, it just sees these as two separate commands.
> # BUT we get the same incorrect result if we place the whole if
> expression into {}
> {
> if { = 4 4 } {
> echo "It is 4"
> }
> {
> echo "It is NOT 4"
> }
> }
This is really the same as the above: {...} allows multiple commands, so
it sees this as two separate commands nested inside the {}.
Ultimately, I think this is closer to a feature request: adding an
"else" token would disambiguate this:
if { = 2 2 } {
echo "good"
}
else {
echo "bad"
}
Actually making this work in Eshell's internals might be painful though...
I do also see a potential bug. I'd expect this to work, but it doesn't:
if { = 2 2 } \
{ echo "good" } \
{ echo "bad" }
This bug report was last modified 2 years and 246 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.