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 #11 received at 59612 <at> debbugs.gnu.org (full text, mbox):

From: Milan Zimmermann <milan.zimmermann <at> gmail.com>
To: 59612 <at> debbugs.gnu.org
Subject: Incorrect behavior also with ${CONDITION}
Date: Sat, 26 Nov 2022 11:19:08 -0500
[Message part 1 (text/plain, inline)]
I should add that I realized using {CONDITION} alone is not a reasonable
thing in my examples, as it uses exist status.

In a real code, one would use  ${CONDITION}. The modified script is
attached below #####. However, the behavior is still not as expected:

~/tmp $ source ./conditionals-bug.esh
It is 2
It is 3
It is NOT 3
It is 4
It is NOT 4


######################################
# The behavior of conditionals depends on whitespace
# Source this script to test it

# This formatting works as expected; evaluates the "true" block.
# Result:
#  "It is 2"
#

if ${= 2 2} {
  echo "It is 2"
} {
   echo "It is NOT 2"
}

# This formatting causes a BUG: both the "true" block and the "false" block
are evaluated.
# I tried several combinations, it appears it the "false" block starts on
it's own line,
# it is no longer treated a part of the "if" expression. Which could be
argued
# is expected because there is no "else" that would define whether the
second block
# is not part of the "if" expression. BUT see next test
#
# Result:
#  "It is 3"
#  "It is NOT 3"
#

if ${ = 3 3 } {
   echo "It is 3"
}
{
   echo "It is NOT 3"
}

# 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"
  }
}
[Message part 2 (text/html, inline)]

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.