all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Milan Zimmermann <milan.zimmermann@gmail.com>, 59666@debbugs.gnu.org
Subject: bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context
Date: Mon, 28 Nov 2022 18:03:41 -0800	[thread overview]
Message-ID: <431174aa-8b2c-84fd-121d-acc6b496b692@gmail.com> (raw)
In-Reply-To: <CAEc2VK2C_tevAHV7PsnbWooaStLQpR+j5P6Xpd9TH47Kjk1H9A@mail.gmail.com>

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 ">".





  reply	other threads:[~2022-11-29  2:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29  0:15 bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context Milan Zimmermann
2022-11-29  2:03 ` Jim Porter [this message]
2022-12-02  1:38 ` Milan Zimmermann
2022-12-02  1:53   ` Jim Porter
2022-12-02  7:33     ` Milan Zimmermann
2022-12-03 19:31       ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=431174aa-8b2c-84fd-121d-acc6b496b692@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=59666@debbugs.gnu.org \
    --cc=milan.zimmermann@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.