all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Milan Zimmermann <milan.zimmermann@gmail.com>
To: 59666-done@debbuggs.gnu.org, 59666-done@debbugs.gnu.org
Subject: bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context
Date: Thu, 1 Dec 2022 20:38:43 -0500	[thread overview]
Message-ID: <CAEc2VK2q35NbkcB7KxuAhZxAd_Qn4Ainw54Myftr_w7ebFm6Ow@mail.gmail.com> (raw)
In-Reply-To: <CAEc2VK2C_tevAHV7PsnbWooaStLQpR+j5P6Xpd9TH47Kjk1H9A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2226 bytes --]

Thanks for your detailed follow up.

I understand what is happening, and am closing this issue (please reopen if
you see fit).

In the closing notes, I have a suggestion (slash question), and a summary
of how to use CONDITIONAL in the 'if' statement - in case it can be of use
for someone reading later.

****** Suggestion / question

Would it be reasonable to suggest removing existing functionality as
follows:

In the statement

if     CONDITIONAL { TRUE-COMMANDS } { FALSE-COMMANDS }

The CONDITIONAL can only have the following forms:

1. ${command-call}
2. ${function-call}

The currently allowed

3. {command-call}
4. (function-call)

would represent syntax error.

(3. is outright wrong as it brings silent invalid results)

By banning 3. and 4., Would Eshell lose the ability to express any
semantics that can be achieved using 1. and 2?


****** Math operations using < or < in ~if CONDITIONAL~

~Quote < and >  as \< or \> with backslash OTHERWISE YOU GET AN ERROR, OR
SILENTLY INCORRECT BEHAVIOR~

inside () or $() quotes are not needed but do not hurt

Examples:

if ${\< 3 5} {echo YES} {echo NO}   # YES -- correct
if ${< 3 5} {echo YES} {echo NO}    # Eshell thinks it is redirection, so
WRONG
if ${> 3 5} {echo YES} {echo NO}    # YES - WRONG!!! (silently)

if $(< 3 5) {echo YES} {echo NO} # YES -- correct
if $(> 3 5) {echo YES} {echo NO} # NO  -- correct
if (< 3 5) {echo YES} {echo NO} # YES -- correct
if (> 3 5) {echo YES} {echo NO} # NO -- correct

****** Flow control: TL;DR of ~if CONDITIONAL~

- Bad:  Do NOT use ~if {function-call}~ (abbreviated, ~if {}~)
- Good: Do use     ~if ${function-call}~  or  ~if $(function-call)~ or ~if
(function-call)~


Examples"
- Bad  use:  ~if {= 3 0}  { echo YES } { echo NO }~  # YES -- WRONG!!!
(silently!!)
- Good use:  ~if ${= 3 0} { echo YES } { echo NO }~  # NO -- correct

****** Flow control: Recipe of ~if CONDITIONAL~

In flow control ~if CONDITIONAL {TRUE-COMMANDS} {FALSE-COMMANDS}~: do NOT
USE the ~{}~ BLOCK as CONDITIONAL; instead use ~the ${}~, ~$()~ or ~()~
blocks. The ~$~ versions are preferred.

The above recipy also applies to ~unless~, ~while~ ~until~. (this does not
apply to ~for VAR in LIST~ which is described elsewhere)

Thanks,

Milan

[-- Attachment #2: Type: text/html, Size: 2636 bytes --]

  parent reply	other threads:[~2022-12-02  1:38 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
2022-12-02  1:38 ` Milan Zimmermann [this message]
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=CAEc2VK2q35NbkcB7KxuAhZxAd_Qn4Ainw54Myftr_w7ebFm6Ow@mail.gmail.com \
    --to=milan.zimmermann@gmail.com \
    --cc=59666-done@debbuggs.gnu.org \
    --cc=59666-done@debbugs.gnu.org \
    /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.