From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#57129: 29.0.50; Improve behavior of conditionals in Eshell Date: Wed, 10 Aug 2022 19:43:22 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8495"; mail-complaints-to="usenet@ciao.gmane.io" To: 57129@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 11 04:44:17 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 1oLyBE-00026d-Kf for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Aug 2022 04:44:16 +0200 Original-Received: from localhost ([::1]:44580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLyBD-0000ac-GE for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Aug 2022 22:44:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLyB0-0000aT-SC for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 22:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oLyB0-0002Do-Ho for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 22:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oLyB0-0007W1-Cl for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 22:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Aug 2022 02:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57129 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166018580928825 (code B ref -1); Thu, 11 Aug 2022 02:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Aug 2022 02:43:29 +0000 Original-Received: from localhost ([127.0.0.1]:51052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oLyAT-0007Ur-4L for submit@debbugs.gnu.org; Wed, 10 Aug 2022 22:43:29 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:60112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oLyAR-0007Ui-9K for submit@debbugs.gnu.org; Wed, 10 Aug 2022 22:43:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLyAR-0000Y5-2q for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 22:43:27 -0400 Original-Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:44915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oLyAP-0002AO-JM for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 22:43:26 -0400 Original-Received: by mail-pl1-x629.google.com with SMTP id d16so15839273pll.11 for ; Wed, 10 Aug 2022 19:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:content-language:mime-version:date :message-id:to:subject:from:from:to:cc; bh=YBdHqhfbcQ04P0XWe5FhP6Eg7r0RRWTfZmED8VfU7Mg=; b=YxDpJDhIn052Epix1NStyFSdbOvuTsXy5pJ0cYD6upPUCzDbt2q/rLNCL0VCKy36XD eNHGBaCcNHioTqG967Vor7uviYd56QyHUnBVrubeSrwXV4nIDvtfini9Cw+FcV6qSzgp h9R+PgA/ilPbJAOrd/UpWsRZ8E771I3g0b0wKaytf+GJRVr45OBHyg+W2GI77j8nHO6l xWgwn8zBFFKmg+8gBYjm6nRFWaPc/AgvPPEkbSZJEImMCUvUe50DXFoPgekzqjLXj9jZ 8CJX69ijV3j8xT/Gy8zM4f4vLWyLVL1W1wo32V5LnhevODhIz1yaW16MKuINgwTkV8b2 52Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:mime-version:date :message-id:to:subject:from:x-gm-message-state:from:to:cc; bh=YBdHqhfbcQ04P0XWe5FhP6Eg7r0RRWTfZmED8VfU7Mg=; b=LOHSxNUxx8DVV2Rt7JBrucph0vC6wb+OOBhZgEhzouCuiQUZ+s6XbjYh4jfdex07CD KSKX2tsq1Mxo7gER+G0O+isdo5vqsL1zGynN1XoxQr52tEbLIizrs7kRZcWVzGBNSPPY meD95LBHJ6WUrl9IXSZ1bCqOzWw7qFoO0W9QzZpAvV58lk+yTny6Tzdq3TW0N71Qi3O5 2lU/5FiEv3eWbXDXEPZYKqODnG8shG9skLNYUwLyLutawv2152HnkEBuRReUqDRYW2BK w9VviIRRQGNQdP/mNNnEYyfsX+bt6HdbrYxBnUVzMHcscm/dwsG/mTDN5R2FmS8TcDGX BSwA== X-Gm-Message-State: ACgBeo2LhU6+TpBaZ8jzMFHng7S/3wGJ7Kh0bXKjLWJaj08DbkA+VYGv h/MPTYPAvOxyYD3+uDBo7SpkKRl1OeQ= X-Google-Smtp-Source: AA6agR6wQMFbFpa5HTIftFLgpS52BpXDr0fN/JoKQVu2yWwRPYfcT466kDGIiHAdkVXuDrw3qIGjyA== X-Received: by 2002:a17:90a:b391:b0:1f3:6c3:392c with SMTP id e17-20020a17090ab39100b001f306c3392cmr6549452pjr.166.1660185803614; Wed, 10 Aug 2022 19:43:23 -0700 (PDT) Original-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 kb7-20020a17090ae7c700b001f56a5e5d2fsm10840882pjb.2.2022.08.10.19.43.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Aug 2022 19:43:22 -0700 (PDT) X-Mozilla-News-Host: news://news.gmane.org:119 Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=jporterbugs@gmail.com; helo=mail-pl1-x629.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:239322 Archived-At: In Eshell, you can use conditionals pretty much like you'd expect from other shells. Starting from 'emacs -Q -f eshell': ~ $ [ foo = foo ] && echo hi hi ~ $ [ foo = bar ] && echo hi ~ $ [ foo = foo ] || echo hi ~ $ [ foo = bar ] || echo hi hi ~ $ if {[ foo = foo ]} {echo yes} {echo no} yes ~ $ if {[ foo = bar ]} {echo yes} {echo no} no However, that only works for external commands. If the command is implemented in Lisp, it doesn't work: ~ $ (zerop 0) && echo hi t hi ~ $ (zerop 1) && echo hi hi ;; Shouldn't say hi. That's because the exit status is always 0 for Lisp commands. This works correctly for external commands: ~ $ [ foo = foo ]; echo status $? result $$ ("status" 0 "result" nil) ~ $ [ foo = bar ]; echo status $? result $$ ("status" 1 "result" nil) But not for Lisp commands: ~ $ (zerop 0); echo status $? result $$ t ("status" 0 "result" t) ~ $ (zerop 1); echo status $? result $$ ("status" 0 "result" nil) ~ $ (zerop "foo"); echo status $? result $$ Wrong type argument: number-or-marker-p, "foo" ("status" 0 "result" nil) The manual says that the status should be 1 when a Lisp command fails, but it's 0 no matter what, even if it signaled an error. (Likewise, the manual says that the "result" variable should be t for successful external commands, but it's always nil.) Similarly to the above, you can't use variable expansions for conditionals: ~ $ (setq foo t) t ~ $ if $foo {echo yes} {echo no} yes ~ $ (setq foo nil) ~ $ if $foo {echo yes} {echo no} yes ;; Should say no. Patch forthcoming. Just splitting it into two messages since it seemed more readable that way...