GNU bug report logs -
#59666
29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context
Previous Next
Full log
Message #8 received at 59666 <at> debbugs.gnu.org (full text, mbox):
On 11/28/2022 4:15 PM, Milan Zimmermann wrote:
> All behavior of comparisons below is incorrect
>
> # Comparisons using ">"
This is actually working as intended, though it's another one of those
surprising behaviors that you tend to get in Eshell due to its fusion of
Lisp and shell syntax.
The problem is that ">" and "<" are I/O redirection operators (though
"<" isn't actually implemented yet). If you want to do a less- or
greater-than comparison using command-style syntax, you'd need to escape it:
~ $ \> 3 2
t
> ### 4.
> ~/tmp $ if {> 3 2} {echo YES} {echo NO}
> Actual: NO
> Expected: YES
One additional note. Even with the proper escapes, that won't work right:
~ $ if {\> 3 2} {echo YES} {echo NO}
YES
~ $ if {\> 3 4} {echo YES} {echo NO}
YES ;; Wrong!
That's because the above form is actually just checking, "Did the Lisp
function '>' signal an error?"[1] You'd need to use ${} expansion, which
expands to the *output* of the subcommand (and then checks that it's
non-nil), or the Lisp form $()/():
~ $ if ${\> 3 2} {echo YES} {echo NO}
YES
~ $ if ${\> 3 4} {echo YES} {echo NO}
NO
~ $ if (> 3 2) {echo YES} {echo NO}
YES
~ $ if (> 3 4) {echo YES} {echo NO}
NO
~ $ if $(> 3 2) {echo YES} {echo NO}
YES
~ $ if $(> 3 4) {echo YES} {echo NO}
NO
Maybe {...} forms should work more like (...) forms when it finds a Lisp
function that's not prefixed with 'eshell/'. I'll have to think about
this some more though...
[1] This is all assuming there's no external program named ">".
This bug report was last modified 2 years and 195 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.