From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Milan Zimmermann Newsgroups: gmane.emacs.bugs 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 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000002bc8105eece687f" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12475"; mail-complaints-to="usenet@ciao.gmane.io" To: 59666-done@debbuggs.gnu.org, 59666-done@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 02:40:58 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0v2w-00031C-GK for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 02:40:58 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0v29-0007lJ-Ls; Thu, 01 Dec 2022 20:40:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0v26-0007kv-RT for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 20:40:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0v26-0003vB-E1 for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 20:40:06 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0v22-0004OY-3H for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 20:40:02 -0500 In-Reply-To: Resent-From: Milan Zimmermann Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 01:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 59666 X-GNU-PR-Package: emacs Mail-Followup-To: 59666@debbugs.gnu.org, milan.zimmermann@gmail.com, milan.zimmermann@gmail.com Original-Received: via spool by 59666-done@debbugs.gnu.org id=D59666.166994516716877 (code D ref 59666); Fri, 02 Dec 2022 01:40:01 +0000 Original-Received: (at 59666-done) by debbugs.gnu.org; 2 Dec 2022 01:39:27 +0000 Original-Received: from localhost ([127.0.0.1]:43147 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0v1S-0004O8-Q4 for submit@debbugs.gnu.org; Thu, 01 Dec 2022 20:39:27 -0500 Original-Received: from mail-vk1-f169.google.com ([209.85.221.169]:36821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0v1R-0004O0-2R for 59666-done@debbugs.gnu.org; Thu, 01 Dec 2022 20:39:25 -0500 Original-Received: by mail-vk1-f169.google.com with SMTP id j14so1693802vkp.3 for <59666-done@debbugs.gnu.org>; Thu, 01 Dec 2022 17:39:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=gBoiboYhkyH/hGOLBs+KhTbMjLAGtmiMvtN7qGwxl8E=; b=l3oU3YPVWOoxz+RDsQ+YyloGxhCcSUPqUSBAX0Axshwmx0CBjeEWdFXXsqTrPfP5+4 mPOmTi/AY/OFJYnhbEt0ogR5KbYwWhKyX87amQdRiwjDb8ZOamh7Ra7kUCKalbdNM+nL gHbk0fPKDktges7KSdC4WYILNx1xboWxbWr5ww/tIrQinxad9/o3C0rhaIUPOHpT0/Ex fgydAUAFu3ppkrudQ3B3szWvtsRVd6rdmx8ui99yEHLrsQu5SO+9h4o4BxT0yXkV7nAO 4GbB0g3B10RC7rEmFYwTVUjB5CZWi2dXlwVrWr4OO7N4ybFFwzzd44OvtSx6v56a2ZIr bNPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=gBoiboYhkyH/hGOLBs+KhTbMjLAGtmiMvtN7qGwxl8E=; b=dWToM+9FepLm9WEkHPySd+HYzBGNRgGVbcejP4dlxfhTLlNBEYqWJi7kSfnF+gNWD+ kNwoBEV+BBMVKeLpt4IZpmLZrG+TU8Gbkn5yNakF2tZ0/rDGuiQ2vXitjqVYnr6Wn9F3 vrJGO68bSLuKYaxSlBSTFMWjN4yIJXyOhJf5n9bnohUSMlZnCvgPTBij9m0s/VCmLxyn ZQcOH7NYOTFoOOCuojWXS6K1NorhocoNfEQN0uFhYHsFGoHhC2MYdhe2s+/XZzgofjG8 AggYNHks828WYsqSxPlvDbG4NH+vjKJMW4bqFe5pF0+wcw9zGkqsNTslFr3YZBpziSvh IJMA== X-Gm-Message-State: ANoB5ploDCM23Fb8UBOYQtkM3fasSAsYDBFxi3ZErJTQ7bZ0vGdk/R9D tKjDBbFb1Hl14nWu0cYVkyAX+dZE2HLAigsZWHIhCB1mZPI= X-Google-Smtp-Source: AA0mqf5uG9ekZX4ocpnfnvuVazYRpDEvxpJTs+UEaaDRYixBqYLS7MnbQG99yuTtXush6U/iOtebNcA2fr1fzOMTYWw= X-Received: by 2002:a1f:1e01:0:b0:3bc:b857:af63 with SMTP id e1-20020a1f1e01000000b003bcb857af63mr20457533vke.32.1669945159235; Thu, 01 Dec 2022 17:39:19 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249685 Archived-At: --00000000000002bc8105eece687f Content-Type: text/plain; charset="UTF-8" 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 --00000000000002bc8105eece687f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for your detailed follow u= p.

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 removin= g existing functionality as follows:

In the statement

if =C2= =A0 =C2=A0 CONDITIONAL { TRUE-COMMANDS } { FALSE-COMMANDS }

The COND= ITIONAL 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 outrig= ht 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 ~i= f CONDITIONAL~

~Quote < and > =C2=A0as \< or \> with bac= kslash OTHERWISE YOU GET AN ERROR, OR SILENTLY INCORRECT BEHAVIOR~

i= nside () or $() quotes are not needed but do not hurt

Examples:
<= br>if ${\< 3 5} {echo YES} {echo NO} =C2=A0 # YES -- correct
if ${<= ; 3 5} {echo YES} {echo NO} =C2=A0 =C2=A0# Eshell thinks it is redirection,= so WRONG
if ${> 3 5} {echo YES} {echo NO} =C2=A0 =C2=A0# YES - WRONG= !!! (silently)

if $(< 3 5) {echo YES} {echo NO} # YES -- correct<= br>if $(> 3 5) {echo YES} {echo NO} # NO =C2=A0-- 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~=C2=A0
- Bad: =C2=A0Do NOT use ~if {function-call}~ (abbreviated, ~if = {}~)
- Good: Do use =C2=A0 =C2=A0 ~if ${function-call}~ =C2=A0or =C2=A0~= if $(function-call)~ or ~if (function-call)~

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

****** Flow control: R= ecipe of ~if CONDITIONAL~

In flow control ~if CONDITIONAL {TRUE-COMM= ANDS} {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
--00000000000002bc8105eece687f--