From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 28 19:16:30 2022 Received: (at submit) by debbugs.gnu.org; 29 Nov 2022 00:16:30 +0000 Received: from localhost ([127.0.0.1]:51862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozoIX-0000UD-E1 for submit@debbugs.gnu.org; Mon, 28 Nov 2022 19:16:30 -0500 Received: from lists.gnu.org ([209.51.188.17]:48334) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozoIV-0000U7-30 for submit@debbugs.gnu.org; Mon, 28 Nov 2022 19:16:27 -0500 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 1ozoIR-0001yz-SZ for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 19:16:26 -0500 Received: from mail-ua1-x92c.google.com ([2607:f8b0:4864:20::92c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ozoIN-0006fp-Ns for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 19:16:22 -0500 Received: by mail-ua1-x92c.google.com with SMTP id y15so4489375uan.6 for ; Mon, 28 Nov 2022 16:16:18 -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=0ZhevKyGorZS7TRmAgouR4MRz/S7LsCAAOFTN3tRFLE=; b=ldtmPdQ9VkzzzkBGjS8BwpCRTJiSeH5tKmjjw8tG/CIJJ0A8p9X/sdAim5FjfHIkZ4 PefqjxDg5fIlLoCtOh3vMuWjJKwTyE89Z85arrC2Edzl58oNpHxB5fXr0XT3Ll4jQNcH ImMQKF4s+05lNRvZOliD6rWBFGK6rpT2EDeU4klbhLyAxar6L3v7lK727Mj6akMxeY5X 3gp488qznErbdr+g1mFHMr5FdxZvuiUH+tk94a0ZhNIAgv1VegOQBVPHBF4p8y/vhmNm xx5XW0uOSf7T6ixfaumI8zi+toLhvUOGw8h5OcYKUJzvUPAKIUhuw3rkCWoS9X4UMTm3 eL/w== 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=0ZhevKyGorZS7TRmAgouR4MRz/S7LsCAAOFTN3tRFLE=; b=fngTJQAZxPcXnwy1dVTEXzn8WmfzuK1pfz5j2a81SW8BEQShsvXlCdA1xnjtHwaAUQ n/Ag1sX4seMxfLBefZiQxnpdIJaYq9ybNOuRfeCFGSPnnOH2JO7ojblfhm6G5eoSRGE3 N9Nhq/fMcjJEmKsLsVt8J0lEY7W82PWrQoSHWYcW/55gnxIlUUKvKZKOwdaLYJoBo26a qyIPkptyiu1qUqWZsgS5UOJpv5J4UfsuNnIeGfui+aQ6kjNgsTnDkugq4507UBi+CcZR 57XiD+0w6OvIkX8BWDSbupFnHQy5uoN3BdqjIVI9L9o1Cn85x3fhnDjWACRh9/veiTMM BmFQ== X-Gm-Message-State: ANoB5pmyXxEeWQyIhKHVMUyBXimyr6iCvS2Lhxzk06IqNdgAKv67Hp9l ZFggi7VXr36WhAuDNoJkWrL5HsTWo1faLoqwpDJhh+IuxDQ= X-Google-Smtp-Source: AA0mqf7IYlUgf5OoMp68Qju8XixxBTv4KGhZ1p2MuaqNpeW5+xp/TaQRFsdxNQRs1fG7M2T41QcW5NCNhsTWHKhHmdo= X-Received: by 2002:ab0:7243:0:b0:3ad:4f5c:66ad with SMTP id d3-20020ab07243000000b003ad4f5c66admr31114538uap.65.1669680977312; Mon, 28 Nov 2022 16:16:17 -0800 (PST) MIME-Version: 1.0 From: Milan Zimmermann Date: Mon, 28 Nov 2022 19:15:41 -0500 Message-ID: Subject: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="0000000000008a812405ee90e577" Received-SPF: pass client-ip=2607:f8b0:4864:20::92c; envelope-from=milan.zimmermann@gmail.com; helo=mail-ua1-x92c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --0000000000008a812405ee90e577 Content-Type: text/plain; charset="UTF-8" Note: I am running this with the following hook removed: (add-hook 'eshell-mode-hook (lambda () (remove-hook 'eshell-alternate-command-hook 'eshell-fix-bad-commands t))) However, not removing it makes no difference to the behavior, the error visibility would be postponed until the 4th try, when eshell asks to provide an alias (making everything even more confusing). =========== Bug report: =========== All behavior of comparisons below is incorrect # Comparisons using ">" ### 1. ~/tmp $ ${> 3 2} Actual: nil: command not found: command not found Expected: t: command not found (same as below in pure elisp) ~/tmp $ $(> 3 2) # pure elisp Actual equals Expected: t: command not found ### 2. ~/tmp $ {> 3 2} Actual: nil: command not found Expected: t ### 3. ~/tmp $ > 3 2 nil: command not found Expected: t # the above shows incorrect result, which can be tested also as follows ### 4. ~/tmp $ if {> 3 2} {echo YES} {echo NO} Actual: NO Expected: YES # Reverse comparisons using "<" ### 5. ~/tmp $ ${< 3 2} Actual: Eshell does not support input redirection Expected: nil: command not found ### 6. ~/tmp $ {< 3 2} Actual: Eshell does not support input redirection Expected: no result, as in (< 3 2) ### 7. ~/tmp $ < 3 2 Actual: Eshell does not support input redirection Expected: nil: command not found Expected: no result, as in (< 3 2) ### 8. The above shows incorrect results, which can be tested in # variants of the following: ~/tmp $ if {< 3 2} {echo YES} {echo NO} Actual: Eshell does not support input redirection Expected: NO In GNU Emacs 29.0.50 (build 1, x86_64-suse-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) System Description: openSUSE Tumbleweed Configured using: 'configure --host=x86_64-suse-linux-gnu --build=x86_64-suse-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --disable-build-details --without-pop --with-mailutils --without-hesiod --with-gameuser=:games --with-kerberos --with-kerberos5 --with-file-notification=inotify --with-modules --enable-autodepend --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --localstatedir=/var --sharedstatedir=/var/lib --libexecdir=/usr/libexec --with-file-notification=yes --enable-locallisppath=/usr/share/emacs/29.0.50/site-lisp:/usr/share/emacs/site-lisp --without-x --with-json --without-xim --with-sound --with-xpm --with-jpeg --with-tiff --with-gif --with-png --with-rsvg --with-dbus --without-xft --without-gpm --with-pgtk --without-native-compilation --with-toolkit-scroll-bars --with-libotf --with-m17n-flt --with-cairo --without-xwidgets --with-dumping=pdumper 'CFLAGS=-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -D_GNU_SOURCE -DGDK_DISABLE_DEPRECATION_WARNINGS -DGLIB_DISABLE_DEPRECATION_WARNINGS' LDFLAGS=-flto=auto' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP XIM GTK3 ZLIB Important settings: value of $LANG: en_CA.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Eshell Minor modes in effect: shell-dirtrack-mode: t eshell-prompt-mode: t eshell-hist-mode: t eshell-pred-mode: t eshell-cmpl-mode: t eshell-proc-mode: t eshell-arg-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-seq rx em-unix em-term term disp-table shell subr-x ehelp em-script em-prompt em-ls em-hist em-pred em-glob em-extpipe em-cmpl em-dirs esh-var pcomplete comint ansi-osc ansi-color ring em-basic em-banner em-alias esh-mode eshell esh-cmd generator esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups esh-util cus-edit pp cus-start cus-load icons wid-edit cl-loaddefs cl-lib files-x rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 78484 13781) (symbols 48 8942 0) (strings 32 24745 2566) (string-bytes 1 734947) (vectors 16 15111) (vector-slots 8 205050 17892) (floats 8 35 34) (intervals 56 421 0) (buffers 984 11)) --0000000000008a812405ee90e577 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
3D""Note: I am run= ning this with the following hook removed:
(add-hook 'eshell-m= ode-hook
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda ()
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (remove-hook
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0'eshell-alternate-command-hook
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0'eshell-fix-bad-commands t)))
However, n= ot removing it makes no difference to the behavior, the error
visibility= would be postponed until the 4th try, when eshell asks to=C2=A0
provide an alias=C2=A0(making everything even more confusing).<= br>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Bug report:
=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D

All behavior of comparisons below is incorrect
# Comparisons using ">"
### 1.
~/tmp $ ${> 3 2}=
Actual: nil: command not found: command not found
Expected: t: comma= nd not found (same as below in pure elisp)

~/tmp $ $(> 3 2) # pur= e elisp
Actual equals Expected: t: command not found


### 2. <= br>~/tmp $ {> 3 2}
Actual: nil: command not found
Expected: t
<= br>### 3.
~/tmp $ > 3 2
nil: command not found
Expected: t
= =C2=A0
# the above shows incorrect result, which can be tested also as f= ollows

### 4.
~/tmp $ if {> 3 2} {echo YES} {echo NO}
Actu= al: NO
Expected: YES

# Reverse comparisons using "<"=

### 5.
~/tmp $ ${< 3 2}
Actual: Eshell does not support i= nput redirection
Expected: nil: command not found

### 6.
~/tm= p $ {< 3 2}
Actual: Eshell does not support input redirection
Expe= cted: no result, as in (< 3 2)

### 7.
~/tmp $ < 3 2
Act= ual: Eshell does not support input redirection
Expected: nil: command no= t found
Expected: no result, as in (< 3 2)

### 8. The above sh= ows incorrect results, which can be tested in
# =C2=A0 =C2=A0 =C2=A0vari= ants of the following:
~/tmp $ if {< 3 2} {echo YES} {echo NO}
Act= ual: Eshell does not support input redirection
Expected: NO


<= br>In GNU Emacs 29.0.50 (build 1, x86_64-suse-linux-gnu, GTK+ Version
3.= 24.34, cairo version 1.17.6)
System Description: openSUSE Tumbleweed
=
Configured using:
=C2=A0'configure --host=3Dx86_64-suse-linux-gn= u --build=3Dx86_64-suse-linux-gnu
=C2=A0--program-prefix=3D --disable-de= pendency-tracking --prefix=3D/usr
=C2=A0--exec-prefix=3D/usr --bindir=3D= /usr/bin --sbindir=3D/usr/sbin
=C2=A0--sysconfdir=3D/etc --datadir=3D/us= r/share --includedir=3D/usr/include
=C2=A0--libdir=3D/usr/lib64 --libexe= cdir=3D/usr/libexec --localstatedir=3D/var
=C2=A0--sharedstatedir=3D/var= /lib --mandir=3D/usr/share/man
=C2=A0--infodir=3D/usr/share/info --disab= le-build-details --without-pop
=C2=A0--with-mailutils --without-hesiod -= -with-gameuser=3D:games
=C2=A0--with-kerberos --with-kerberos5 --with-fi= le-notification=3Dinotify
=C2=A0--with-modules --enable-autodepend --pre= fix=3D/usr
=C2=A0--mandir=3D/usr/share/man --infodir=3D/usr/share/info -= -datadir=3D/usr/share
=C2=A0--localstatedir=3D/var --sharedstatedir=3D/v= ar/lib
=C2=A0--libexecdir=3D/usr/libexec --with-file-notification=3Dyes<= br>=C2=A0--enable-locallisppath=3D/usr/share/emacs/29.0.50/site-lisp:/usr/s= hare/emacs/site-lisp
=C2=A0--without-x --with-json --without-xim --with-= sound --with-xpm
=C2=A0--with-jpeg --with-tiff --with-gif --with-png --w= ith-rsvg --with-dbus
=C2=A0--without-xft --without-gpm --with-pgtk --wit= hout-native-compilation
=C2=A0--with-toolkit-scroll-bars --with-libotf -= -with-m17n-flt --with-cairo
=C2=A0--without-xwidgets --with-dumping=3Dpd= umper 'CFLAGS=3D-O2 -Wall
=C2=A0-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE= =3D3 -fstack-protector-strong
=C2=A0-funwind-tables -fasynchronous-unwin= d-tables -fstack-clash-protection
=C2=A0-Werror=3Dreturn-type -flto=3Dau= to -D_GNU_SOURCE
=C2=A0-DGDK_DISABLE_DEPRECATION_WARNINGS -DGLIB_DISABLE= _DEPRECATION_WARNINGS'
=C2=A0LDFLAGS=3D-flto=3Dauto'

Conf= igured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS H= ARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOT= IFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
= TOOLKIT_SCROLL_BARS WEBP XIM GTK3 ZLIB

Important settings:
=C2=A0= value of $LANG: en_CA.UTF-8
=C2=A0 value of $XMODIFIERS: @im=3Dibus
= =C2=A0 locale-coding-system: utf-8-unix

Major mode: Eshell

Mi= nor modes in effect:
=C2=A0 shell-dirtrack-mode: t
=C2=A0 eshell-prom= pt-mode: t
=C2=A0 eshell-hist-mode: t
=C2=A0 eshell-pred-mode: t
= =C2=A0 eshell-cmpl-mode: t
=C2=A0 eshell-proc-mode: t
=C2=A0 eshell-a= rg-mode: t
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mode: t
=C2= =A0 show-paren-mode: t
=C2=A0 electric-indent-mode: t
=C2=A0 mouse-wh= eel-mode: t
=C2=A0 tool-bar-mode: t
=C2=A0 menu-bar-mode: t
=C2=A0= file-name-shadow-mode: t
=C2=A0 global-font-lock-mode: t
=C2=A0 font= -lock-mode: t
=C2=A0 blink-cursor-mode: t
=C2=A0 line-number-mode: t<= br>=C2=A0 indent-tabs-mode: t
=C2=A0 transient-mark-mode: t
=C2=A0 au= to-composition-mode: t
=C2=A0 auto-encryption-mode: t
=C2=A0 auto-com= pression-mode: t

Load-path shadows:
None found.

Features:<= br>(shadow sort mail-extr emacsbug message mailcap yank-media puny direddired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068epg-config gnus-util text-property-search time-date mm-decode mm-bodiesmm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
= rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-seq rx
em-un= ix em-term term disp-table shell subr-x ehelp em-script em-prompt
em-ls = em-hist em-pred em-glob em-extpipe em-cmpl em-dirs esh-var
pcomplete com= int ansi-osc ansi-color ring em-basic em-banner em-alias
esh-mode eshell= esh-cmd generator esh-ext esh-opt esh-proc esh-io
esh-arg esh-module es= h-groups esh-util cus-edit pp cus-start cus-load
icons wid-edit cl-loadd= efs cl-lib files-x rmc iso-transl tooltip cconv
eldoc paren electric uni= quify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/pgtk-wi= n pgtk-win term/common-win pgtk-dnd
tool-bar dnd fontset image regexp-op= t fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode= register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer selec= t scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors f= rame minibuffer nadvice seq
simple cl-generic indonesian philippine cham= georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao kore= an japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european= ethiopic indian
cyrillic chinese composite emoji-zwj charscript charpro= p case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-prel= oaded button
loaddefs theme-loaddefs faces cus-face macroexp files windo= w
text-properties overlay sha1 md5 base64 format env code-pages mule
= custom widget keymap hashtable-print-readable backquote threads dbusbindinotify dynamic-setting system-font-setting font-render-setting cairo
g= tk pgtk lcms2 multi-tty make-network-process emacs)

Memory informati= on:
((conses 16 78484 13781)
=C2=A0(symbols 48 8942 0)
=C2=A0(stri= ngs 32 24745 2566)
=C2=A0(string-bytes 1 734947)
=C2=A0(vectors 16 15= 111)
=C2=A0(vector-slots 8 205050 17892)
=C2=A0(floats 8 35 34)
= =C2=A0(intervals 56 421 0)
=C2=A0(buffers 984 11))
=
--0000000000008a812405ee90e577-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 28 21:03:52 2022 Received: (at 59666) by debbugs.gnu.org; 29 Nov 2022 02:03:52 +0000 Received: from localhost ([127.0.0.1]:52310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozpyR-0001eH-Tp for submit@debbugs.gnu.org; Mon, 28 Nov 2022 21:03:52 -0500 Received: from mail-pl1-f177.google.com ([209.85.214.177]:44927) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozpyQ-0001e9-1n for 59666@debbugs.gnu.org; Mon, 28 Nov 2022 21:03:50 -0500 Received: by mail-pl1-f177.google.com with SMTP id g10so11996132plo.11 for <59666@debbugs.gnu.org>; Mon, 28 Nov 2022 18:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=wyyZwtL0AoFflaDLW0NTUsetiZQ2Evao5UEMPKLGoHk=; b=fQTNT3aqMif5G3uQ15MN/Bn4+nSoMTnU3XjIFgpZyCZAK8lxmM4lLJoc7uGfddSydk 8ZF9riqRVHya+6xQJ9BYhV/xj8wao6k7wVRyQ4rUWRdQeP6fWlNSSlVMEgdhkukHeJNA pQ8DKjetxg1eiZGMJnrAstB9WbXoiRZEMrDjV3St5KcqihjVakUWN0bknRFHPK7wrwbe OWXmb45ITWpkZ+8pLPDW/h0dDp1d9sGjGz4OBJWP71rN4Ft0FxI8RN1wDTbnjwvNkfem nDLGsjZa+6/YrI2wnmZ+QQUHbvPL+4f0WAc5JJn+IPEhoEGIGnNmfXB6NDGBrj5K8UFR s3Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wyyZwtL0AoFflaDLW0NTUsetiZQ2Evao5UEMPKLGoHk=; b=ZryC8D9AWr/8aGMQvBDETP2wpnHyMExrqoiQ8Y5p0UIMaB3E/yUL1rWMlcJqXEUH43 vxYHIUHtMiisL1EIUb842Xxb5UdrOodTcNXaUeWctysRpWCcvt7vZ9XvKhMxCts8gvcu KdYhaEKjRd2ov98Tyz/lZlMQI1kfStox92QIZPnkJZxwGBXXJ3uuMtt/dUdlWzEGDceb XV4jiwPkpWz7fUuOXR1NK98l69sMSSAvHgFN04mOznxiNVOQpEUU968+tZXvPBXA5+Gc sXY3LyvOEqWpGp+lDY1ivvscWKNCezjs9wO1qUtSY/pDPRG5OG49UUUBDyFBL5Crc7+G 8rMg== X-Gm-Message-State: ANoB5pkJF+iomDZMoQzp2A9BDAXoGgvCwu++Egwch/vmvtBuft4LH2R5 GuI5KDZp9V/w2sM612mVpIE= X-Google-Smtp-Source: AA0mqf75RFLG5SiEWn2X6jUaG1cr+4MP0YoCduOzSzErYuL1coR/h9Zs9ha53elxmFhIYqPXB/40IQ== X-Received: by 2002:a17:902:cf4b:b0:186:7a1d:b6ee with SMTP id e11-20020a170902cf4b00b001867a1db6eemr40345314plg.67.1669687422962; Mon, 28 Nov 2022 18:03:42 -0800 (PST) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id o3-20020a170902d4c300b00172951ddb12sm273414plg.42.2022.11.28.18.03.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 18:03:42 -0800 (PST) Message-ID: <431174aa-8b2c-84fd-121d-acc6b496b692@gmail.com> Date: Mon, 28 Nov 2022 18:03:41 -0800 MIME-Version: 1.0 Subject: Re: bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context Content-Language: en-US To: Milan Zimmermann , 59666@debbugs.gnu.org References: From: Jim Porter In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59666 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 ">". From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 20:39:27 2022 Received: (at 59666-done) by debbugs.gnu.org; 2 Dec 2022 01:39:27 +0000 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 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 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) MIME-Version: 1.0 From: Milan Zimmermann Date: Thu, 1 Dec 2022 20:38:43 -0500 Message-ID: Subject: Re: bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context To: 59666-done@debbuggs.gnu.org, 59666-done@debbugs.gnu.org Content-Type: multipart/alternative; boundary="00000000000002bc8105eece687f" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59666-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --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-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 20:54:10 2022 Received: (at 59666) by debbugs.gnu.org; 2 Dec 2022 01:54:10 +0000 Received: from localhost ([127.0.0.1]:43213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0vFh-0004Vb-RQ for submit@debbugs.gnu.org; Thu, 01 Dec 2022 20:54:10 -0500 Received: from mail-pj1-f45.google.com ([209.85.216.45]:45054) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0vFc-0004VE-91 for 59666@debbugs.gnu.org; Thu, 01 Dec 2022 20:54:08 -0500 Received: by mail-pj1-f45.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so3843824pjo.3 for <59666@debbugs.gnu.org>; Thu, 01 Dec 2022 17:54:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=EHQ0pDVLje7T2sEi/SsLF5KWkeqWl3gcbQYzDaQvqyM=; b=N4n2Uyp6TnjNj0uuRnwou1aUpPe1Sls9QwyBA4jI0K3k5oWLe6SL3WfiNGVWyap4lC 3hkfAXdIApg0BkY0mQCJZ6zDPAt8lRZybJkpVvdbSQTW4oPeWwtY4/gII0Vfh/tcSWKO iIOO3P6yq3S1ucs7vMKg1cdCscpFn1m4tGunViaGOTdJe6nZIi+ZDhIXnxX5+zHt7IYK dVxQjOQIFIG6APDWosLrLRKRH9XFHgtoBAeXr6BVaXC1nNYplFLQAbyY9w1PHpbU5rMs rN3MN6Mi4tUOIziFTBmZIDulVFbie9GETvkclzErWgPUpCYXW/NJ4TEaEFjfeCb2/0BP 4SwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EHQ0pDVLje7T2sEi/SsLF5KWkeqWl3gcbQYzDaQvqyM=; b=EqQ+6MlzBshI4M9PEOD0/9O7O2M7hf9/jbFvlLy11+9IBjX82cZx4B8Y1ROqhdHDzr 51DF02wTOCgovbMIOLNXBV+zF890SeDe2ckejwbNIbTGugxdG3PbpvAi9zZs3c+E0J8B yKwYAmDzHsAhL/GMrcmlh+3MygEvO9JS9ZtP8EWDPrv2U2eQV3ZO5V2E/Dd45s1xZ65l VPThcKJtlqRQe8NIyOoPc+3QbKEtLUfOxuTeC11coR66SWNi5G0+DbwxKbcFshzkZhH2 JAQf+wYCg7UIT21bFBcYdd0ZPL752rPdfY3O8+QLFVoAdZSWSDRLpz5mRleLXBBsVqi0 G+GQ== X-Gm-Message-State: ANoB5plBue0HHdLx8ezZUkp8B9vBm6UnYlvsfyeyaPsKbuCS1+ndhMA5 yoKXtP8CAH7egZnXuWUs/xspKwR6OGk= X-Google-Smtp-Source: AA0mqf7LqVyFPHQSaGRmE1z1ExPPlCgXrF+2Lo2VReL1f1SUex/s/sJLywgxIqCOQDwFKAKG//fVhg== X-Received: by 2002:a17:90a:3da1:b0:219:61e5:4994 with SMTP id i30-20020a17090a3da100b0021961e54994mr11819522pjc.213.1669946038426; Thu, 01 Dec 2022 17:53:58 -0800 (PST) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id g6-20020a63fa46000000b0046f469a2661sm3124191pgk.27.2022.12.01.17.53.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Dec 2022 17:53:57 -0800 (PST) Message-ID: Date: Thu, 1 Dec 2022 17:53:57 -0800 MIME-Version: 1.0 Subject: Re: bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context Content-Language: en-US To: 59666@debbugs.gnu.org, milan.zimmermann@gmail.com References: From: Jim Porter In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59666 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 12/1/2022 5:38 PM, Milan Zimmermann wrote: > Would it be reasonable to suggest removing existing functionality as > follows: [snip] > The currently allowed > > 3. {command-call} > 4. (function-call) > > would represent syntax error. > > (3. is outright wrong as it brings silent invalid results) Both 3 and 4 are valid forms, although I think (lisp) and $(lisp) are equivalent. In particular, 3 is important for being able to check the exit status of external programs: ~ $ if {sh -c 'exit 0'} {echo yes} {echo no} yes ~ $ if {sh -c 'exit 1'} {echo yes} {echo no} no ~ $ if ${sh -c 'exit 0'} {echo yes} {echo no} no ;; Wrong! ~ $ if ${sh -c 'exit 1'} {echo yes} {echo no} no I think there's an argument that {lisp-function} should work the same as ${lisp-function}, but only for "regular" Lisp functions (i.e. excluding eshell/FOO ones; since those are designed to imitate external commands, they have different semantics). From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 02:33:55 2022 Received: (at 59666) by debbugs.gnu.org; 2 Dec 2022 07:33:55 +0000 Received: from localhost ([127.0.0.1]:44944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p10YV-00034m-3w for submit@debbugs.gnu.org; Fri, 02 Dec 2022 02:33:55 -0500 Received: from mail-ua1-f50.google.com ([209.85.222.50]:37749) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p10YS-00034g-NQ for 59666@debbugs.gnu.org; Fri, 02 Dec 2022 02:33:53 -0500 Received: by mail-ua1-f50.google.com with SMTP id x24so1412216uaf.4 for <59666@debbugs.gnu.org>; Thu, 01 Dec 2022 23:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Fu+wpj6HWXlDUqAUJE8LAjpRkk+1CM1eCoJZCYULVaY=; b=I1fxPcZVEUWnW73iE+TdbVH3a593M2RIscK2DtUjZ0ASR/sbcNMdTGwT3sJw5LU9Q/ 2K+wjUUXM//ytDAs9vxV9UsqJOB3ya07p9+lG8BE5hVVw3WZ198uqd/x/Kd4uoKNrsOk CdGD5u0KB2MhvhK3eSCB0soNby782C9to0Egspbico81QRws6hjdDxOzp+BEcRTJonsk Cvkx5T2ME2Wm4M1wXY0yWEPj7G8VypAPSrXhjJJ7cCXUU5P5k0LAOgTNsIrR9MHqdmMR lseQDdwEOowRcrB/or12rAUA9p7fIhmgKXOL3slYGDBcWiAGBntDCr8OKvsNdq8KyFsG i1og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Fu+wpj6HWXlDUqAUJE8LAjpRkk+1CM1eCoJZCYULVaY=; b=QbJXQQ+YfRNJmJVATgzhqsigA58WrhiAN9hE9ID9CUROLbzz4Yopkd8K8pvlMK5cim P4YZwzelj1SeUqNxiLP9Qjw1K3IzAp1eEaK8MXFwOC/tHY7/szMdwyOuNnFq3plaDtRy KUHSqxWitA2ItYFESVwad+pEmYxEyRsPAZu2mFxCiF4kZPllzlHczo/tYdAuOFCe2yts pvJPfcvG18MlUZVjoJzxvZO4Gjmcid2sFLOUu4YNLuXuDVTylOG2zwsGSoQ1aLGZiwRm xXVWeikVPZb/Pidjjkvmkn7ndt+AJJm1G/XTRDbsvbOf5hqWE7+7liMAiSu6GwdiLfIR k3JA== X-Gm-Message-State: ANoB5pllgf/I/wItGPvzwhKQW7xNW1oPLAhbXleRDRhDN+7l4Px/5vgr /Fz6q5/YY/8Pv1dcs9Ql8/CpXR0zBNST7ymUIBQ= X-Google-Smtp-Source: AA0mqf5zTSG2JQXqXBiGUM4q6cCHrDKzF+4HEzZvVBcuUlqPcyCuzqf4uvfeht1rtovnf8tikO4gs25UFb8eRKQuXpw= X-Received: by 2002:ab0:7243:0:b0:3ad:4f5c:66ad with SMTP id d3-20020ab07243000000b003ad4f5c66admr40481188uap.65.1669966426991; Thu, 01 Dec 2022 23:33:46 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Milan Zimmermann Date: Fri, 2 Dec 2022 02:33:11 -0500 Message-ID: Subject: Re: bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context To: Jim Porter Content-Type: multipart/alternative; boundary="000000000000aaefbc05eed35bde" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59666 Cc: 59666@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000aaefbc05eed35bde Content-Type: text/plain; charset="UTF-8" On Thu, Dec 1, 2022 at 8:53 PM Jim Porter wrote: > On 12/1/2022 5:38 PM, Milan Zimmermann wrote: > > Would it be reasonable to suggest removing existing functionality as > > follows: > [snip] > > The currently allowed > > > > 3. {command-call} > > 4. (function-call) > > > > would represent syntax error. > > > > (3. is outright wrong as it brings silent invalid results) > > Both 3 and 4 are valid forms, although I think (lisp) and $(lisp) are > equivalent. In particular, 3 is important for being able to check the > exit status of external programs: > > ~ $ if {sh -c 'exit 0'} {echo yes} {echo no} > yes > ~ $ if {sh -c 'exit 1'} {echo yes} {echo no} > no > ~ $ if ${sh -c 'exit 0'} {echo yes} {echo no} > no ;; Wrong! > ~ $ if ${sh -c 'exit 1'} {echo yes} {echo no} > no > > Ah, thanks for pointing this out. I kept searching for a practical semantics that justifies use of if {}. This is definitely important, non-replaceable syntax. My suggestion to ban it was definitely incorrect then. > I think there's an argument that {lisp-function} should work the same as > ${lisp-function}, but only for "regular" Lisp functions (i.e. excluding > eshell/FOO ones; since those are designed to imitate external commands, > they have different semantics). > I agree. I did not find a situation where {lisp-function} and ${lisp-function} would behave differently, but I have not looked yet. So I put the following to my notes, based on your suggestions. If anyone else is reading, please disregard my earlier suggestion to disallow the "if {..}" form. Justified by checking external programs status. 1. use ~if {function-call}~ (only?) to check EXIT STATUS of the EXTERNAL function (program) call. 2. use ~if ${function-call}~ for everything else Eshell, including internal functions passed exported variables (as they force Eshell syntax) 3. use ~if (elisp-function-call)~ for everything pure-elisp, including elisp functions passed setq-ed variables 4. use ~if $(elisp-function-call)~ seems equivalent and interchangeable with the above Examples of 1. - check exit status of EXTERNAL program - if {sh -c 'exit 0'} {echo "external succeeded"} {echo "external failed"} # external succeeded - if {sh -c 'exit 1'} {echo "external succeeded"} {echo "external failed"} # external failed - if ${sh -c 'exit 0'} {echo "external succeeded"} {echo "external failed"} # WRONG external failed - if ${sh -c 'exit 1'} {echo "external succeeded"} {echo "external failed"} # external failed - Other example, if we want to check for success/failure in sed before calling it - # just to test: echo "aaa" | sed 's/aaa/bbb/' # bbb - if {echo "aaa" | sed 's/aaa/bbb/'} {echo sed-success} {echo sed-failure} # sed-success - # just to test: echo "aaa" | sed 's/aaa/bbb' # /usr/bin/sed: -e expression #1, char 9: unterminated `s' command - if {echo "aaa" | sed 's/aaa/bbb'} {echo sed-success} {echo sed-failure} # sed-failure Examples - export a="3" - Bad use: if {equal $a "0"} { echo YES } { echo NO } # YES -- WRONG!!! (silently!!) - Good use: if ${equal $a "0"} { echo YES } { echo NO } # NO -- correct --000000000000aaefbc05eed35bde Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Dec 1, 2022 at 8:53 PM Jim Porter <= jporterbugs@gmail.com> wrot= e:
On 12/1/2022 5:38 PM, Milan Zimmerman= n wrote:
> Would it be reasonable to suggest removing existing functionality as <= br> > follows:
[snip]
> The currently allowed
>
> 3. {command-call}
> 4. (function-call)
>
> would represent syntax error.
>
> (3. is outright wrong as it brings silent invalid results)

Both 3 and 4 are valid forms, although I think (lisp) and $(lisp) are
equivalent. In particular, 3 is important for being able to check the
exit status of external programs:

=C2=A0 =C2=A0~ $ if {sh -c 'exit 0'} {echo yes} {echo no}
=C2=A0 =C2=A0yes
=C2=A0 =C2=A0~ $ if {sh -c 'exit 1'} {echo yes} {echo no}
=C2=A0 =C2=A0no
=C2=A0 =C2=A0~ $ if ${sh -c 'exit 0'} {echo yes} {echo no}
=C2=A0 =C2=A0no=C2=A0 ;; Wrong!
=C2=A0 =C2=A0~ $ if ${sh -c 'exit 1'} {echo yes} {echo no}
=C2=A0 =C2=A0no


Ah, thanks for pointing this out. I kept searchin= g for a practical semantics that justifies use of if {}. This is definitely= important, non-replaceable=C2=A0syntax. My suggestion to ban it was defini= tely incorrect then.
=C2=A0
I think there's an argument that {lisp-function} should work the same a= s
${lisp-function}, but only for "regular" Lisp functions (i.e. exc= luding
eshell/FOO ones; since those are designed to imitate external commands, they have different semantics).

I agree= . I did not find a situation where {lisp-function} and ${lisp-function} wou= ld behave differently, but I have not looked yet.

=
So I put the following to my notes, based on your suggestion= s. If anyone else is reading, please disregard my earlier suggestion to dis= allow the "if {..}" form. Justified by checking external programs= status.

1. use ~if {function-call}~ =C2=A0(only?)= to check EXIT STATUS of the EXTERNAL function (program) call.
2. use ~= if ${function-call}~ for everything else Eshell, including internal functio= ns passed exported variables (as they force Eshell syntax)
3. use ~if (e= lisp-function-call)~ =C2=A0for everything pure-elisp, including elisp funct= ions passed setq-ed variables
4. use ~if $(elisp-function-call)~ seems e= quivalent and interchangeable with the above


Examples of 1. - ch= eck exit status of EXTERNAL program
- if {sh -c 'exit 0'} {echo = "external succeeded"} {echo "external failed"} # extern= al succeeded
- if {sh -c 'exit 1'} {echo "external succeede= d"} {echo "external failed"} =C2=A0# external failed
- if= ${sh -c 'exit 0'} {echo "external succeeded"} {echo &quo= t;external failed"} # WRONG external failed
- if ${sh -c 'exit = 1'} {echo "external succeeded"} {echo "external failed&q= uot;} # external failed
- Other example, if we want to check for success= /failure in sed before calling it
=C2=A0 - # just to test: echo "aa= a" | sed 's/aaa/bbb/' =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0# bbb
=C2=A0 - if {echo "aaa" | sed 's/aa= a/bbb/'} {echo sed-success} {echo sed-failure} # sed-success
=C2=A0 = - # just to test: echo "aaa" | sed 's/aaa/bbb' =C2=A0 =C2= =A0 =C2=A0# /usr/bin/sed: -e expression #1, char 9: unterminated `s' co= mmand
=C2=A0 - if {echo "aaa" | sed 's/aaa/bbb'} {echo= sed-success} {echo sed-failure} =C2=A0# sed-failure


Examples- export a=3D"3"
- Bad use: =C2=A0if {equal $a "0"}= =C2=A0 { echo YES } { echo NO } =C2=A0 # YES =C2=A0-- WRONG!!! (silently!!= )
- Good use: if ${equal $a "0"} =C2=A0{ echo YES } { echo NO = } =C2=A0 # NO -- correct

--000000000000aaefbc05eed35bde-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 03 14:31:10 2022 Received: (at 59666) by debbugs.gnu.org; 3 Dec 2022 19:31:10 +0000 Received: from localhost ([127.0.0.1]:52928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1YEA-0000Ox-Ks for submit@debbugs.gnu.org; Sat, 03 Dec 2022 14:31:10 -0500 Received: from mail-pj1-f43.google.com ([209.85.216.43]:54014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1YE8-0000Oq-On for 59666@debbugs.gnu.org; Sat, 03 Dec 2022 14:31:09 -0500 Received: by mail-pj1-f43.google.com with SMTP id t17so7787996pjo.3 for <59666@debbugs.gnu.org>; Sat, 03 Dec 2022 11:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=VvwOEUir9qnlU7XKOkzUCn1u4RGK7foeC+6eBOCPMcg=; b=dI7KX1AfnZR2EUFt5xm5xESS8HQVoCd1dT/ZXgWQt2TxcLu9yiFBD14n37uRBRPTrZ 2vrZLDC/mBuQpNpiwydrfrM2LdbQ5Qe6oKMOjfg1viNM94Dpb8z2FfGd4c8zrMl3lQDg 0gxEMHkBm5F4OuGeyIneuvhaNizKqoHw48qjNLpmMhLf1nkP4ZqfI33XAu2M2z4S2HZn 7dYdOc3Ia0o8WfNV5UJCSVzy9y3q8ZuDQbJwbDuMgrpTkv6yN9oAIj6cdGgz6yuqIPNZ 9vqXBnayAx4W9rah/t/mjOPVilxWSOX5/TTf+h6s0vig9nmD+N/580PpYjPFPMsib/Ct WMLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VvwOEUir9qnlU7XKOkzUCn1u4RGK7foeC+6eBOCPMcg=; b=4+cIy+2UtKB7X8xUre9tT5rqnO//M8ujvFwfmjUUgEsF8FyQqI07SaKjnRYH4B0N0F 1pOkwoI29VJtvvQhFg8etUfqNp6Z6a80ZLQZoDDzYCTpXodIsMjnafKuyIsoN7sBIEok NPWI6rLINlbMt7Wr3UlYMwru5Gm03BTyEQ8ggzsuk06G7PfgHJrCtZPwk5m1sq1bQ7uJ E69nCOFXdZccOf6+cGZ8/zXTMESu8PX8c5I7OqjQ8f/n1OKFMessKqMRmFoNtbxPVARC dXHucnIFEdk3hOwHR570za6pVU/oIA94P1yRP58he1cYic7J+utH2bvKC8wYXf4c8Gwd mrCQ== X-Gm-Message-State: ANoB5plEb4E+6J3Hp2ENX4Uu3fO0+MU15KWjtTrMYommLZ5N97UmzkoG AfkEj2Y6U7eA2u6OfZRc7DY= X-Google-Smtp-Source: AA0mqf6oj9XZmTyDbzDv3KQ58x75epHhofLwHMwTKZRTKeXewzzWMuZLeRZVCkdTK6WgWYQEoJtwyA== X-Received: by 2002:a17:90a:bf0d:b0:219:3418:db4c with SMTP id c13-20020a17090abf0d00b002193418db4cmr33048631pjs.242.1670095863002; Sat, 03 Dec 2022 11:31:03 -0800 (PST) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id mv15-20020a17090b198f00b0021937b2118bsm8500478pjb.54.2022.12.03.11.31.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Dec 2022 11:31:02 -0800 (PST) Message-ID: <5f8cf571-52d0-9d54-1296-69c5abd2e097@gmail.com> Date: Sat, 3 Dec 2022 11:31:00 -0800 MIME-Version: 1.0 Subject: Re: bug#59666: 29.0.50; Eshell: comparisons such as {> 3 2} do not work in Eshell context To: Milan Zimmermann References: Content-Language: en-US From: Jim Porter In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59666 Cc: 59666@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 12/1/2022 11:33 PM, Milan Zimmermann wrote: > 1. use ~if {function-call}~  (only?) to check EXIT STATUS of the > EXTERNAL function (program) call. One final note is that this should also work for Eshell commands (ones defined as "defun eshell/FOO"), since those are specially-written to conform to Eshell's command behavior. (That is, if they want to report an error, they set the exit status.) From unknown Mon Jul 14 08:31:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 01 Jan 2023 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator