[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59612: 29.0.50; Eshell: The behavior of conditionals depends on whit
From: |
Jim Porter |
Subject: |
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" }