GNU bug report logs - #59612
29.0.50; Eshell: The behavior of conditionals depends on whitespace

Previous Next

Package: emacs;

Reported by: Milan Zimmermann <milan.zimmermann <at> gmail.com>

Date: Sat, 26 Nov 2022 15:54:02 UTC

Severity: normal

Found in version 29.0.50

Full log


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

From: Jim Porter <jporterbugs <at> gmail.com>
To: Milan Zimmermann <milan.zimmermann <at> gmail.com>, 59612 <at> debbugs.gnu.org
Subject: Re: bug#59612: 29.0.50; Eshell: The behavior of conditionals depends
 on whitespace
Date: Sat, 26 Nov 2022 10:42:42 -0800
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.