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#59612: 29.0.50; Eshell: The behavior of conditionals depends on whitespace Date: Sat, 26 Nov 2022 19:13:31 -0800 Message-ID: <7f19f7fa-6573-23de-e0b9-81683dd3b61c@gmail.com> References: <8fec9d79-4118-eaa5-b762-c57f11f41aef@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7735"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59612@debbugs.gnu.org To: Milan Zimmermann Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 27 04:14:27 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 1oz87e-0001pz-OP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Nov 2022 04:14:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oz87J-00036L-J9; Sat, 26 Nov 2022 22:14:05 -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 1oz87H-00033A-QW for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 22:14:03 -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 1oz87G-0003La-I2 for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 22:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oz87G-0002Pl-20 for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 22:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Nov 2022 03:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59612 X-GNU-PR-Package: emacs Original-Received: via spool by 59612-submit@debbugs.gnu.org id=B59612.16695188219268 (code B ref 59612); Sun, 27 Nov 2022 03:14:02 +0000 Original-Received: (at 59612) by debbugs.gnu.org; 27 Nov 2022 03:13:41 +0000 Original-Received: from localhost ([127.0.0.1]:41790 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz86u-0002PQ-MP for submit@debbugs.gnu.org; Sat, 26 Nov 2022 22:13:40 -0500 Original-Received: from mail-pf1-f178.google.com ([209.85.210.178]:43656) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz86s-0002PJ-IP for 59612@debbugs.gnu.org; Sat, 26 Nov 2022 22:13:39 -0500 Original-Received: by mail-pf1-f178.google.com with SMTP id q12so3321702pfn.10 for <59612@debbugs.gnu.org>; Sat, 26 Nov 2022 19:13:38 -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:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=Y1Q1ygZRG23TSVOfGtpQGyACbxp219vNwQbVUBZlYRc=; b=KzZRPYSvKRePs5mLsA0LAQqy/SOsbizmlBkileQWKNSFrrazmEHBboGmamnYiXKlm5 LbKw/gDZOPvdeqgJsVJ0Z89Um3fazgAtHC59P13pBPWiL7sn2p9KadeSFIWvwTaYvoOF YHJ2quJDMgO3/HzJE6Zx/ZAFASYJc7w7fkoUHK2IRY7AY6oxAOf1kiAoWSBaaSKwNqRW D6MZKEyZ9guCxLzBJWzJug9XswFRZ9typ08LEDX/eWyfK9YZux9VTVMlwyBPXu9Zkw84 uuXHAXAXYmcuCepNNHvNLuSbL2Dgp9epegF85QmnhFP9BmmS1Puf1mSUe3IIfiHnui7u 5iaA== 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:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y1Q1ygZRG23TSVOfGtpQGyACbxp219vNwQbVUBZlYRc=; b=PhtQq6pDRs6ZNLZipLo3TIWwRuEQMTc97lkBhm8NbuhoxU3eGdnPAHNRi0dRD0zDy8 dNO1VEgILJm3R15rWIeUGOQ2uQ0HRRzfq4/EpVShKMvBVZnF3M6TLVm4G1dYMi1Og6RU MYLmDD8XXFuTUXOhyyok3ECKshamX6RjLWBDQwbi9QMSQhV7VICRckgTamAjALAAI5ms V54G/sKDDBdUYuqG5JrMm4Uc6QyATP8ZVCu0dV1Y1A7R53sHmFwchxaiBk80zPpjVUZK V0WTQqtqAGD2lZtdqv5Dt3KPlp+S3NsRBv2C8y1xPlRYe5L7BT9+Vcpuvy099cYwZtXI eSAA== X-Gm-Message-State: ANoB5pkvvqHMnESEzD5z+zPt6zbXfQrhG6Y/8s5cM6Hb+XF+w4Dg6XWX BppDmMq+QIBN9p0JGQiyKBg= X-Google-Smtp-Source: AA0mqf4ibKrPlMXVnB0ST7KCsWVXTv1IE+WI7CQ7sJFa0C4kKsAqPZQi9lqipGQTEKqE8MmOXrp8IA== X-Received: by 2002:a05:6a00:2883:b0:572:7b49:4f47 with SMTP id ch3-20020a056a00288300b005727b494f47mr28036619pfb.16.1669518812577; Sat, 26 Nov 2022 19:13:32 -0800 (PST) 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 mv11-20020a17090b198b00b0021358bd24b9sm7244981pjb.21.2022.11.26.19.13.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 26 Nov 2022 19:13:31 -0800 (PST) Content-Language: en-US In-Reply-To: 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:249164 Archived-At: On 11/26/2022 6:16 PM, Milan Zimmermann wrote: > Jim, thanks for the follow-up. Please feel free to close this. I think it would be reasonable to leave this open to track adding support for some kind of "command re-joining" logic that things like if/else forms could use. Then something like this would just work: if { condition } { true-case } else { false-case } At a high level, I'm thinking something like this: 1. Enhance 'eshell-rewrite-if-command' to support "if"/"else if"/"else" forms. 2. Add some top-level command-rewriting logic that lets you join multiple separate commands back into one. I think Eshell splits the commands up line-by-line pretty early in the process, so re-joining them later might be the least-invasive way to do this. It'll take some further diagnosis though. > Yes, I agree. From the way of thinking "whitespace should not matter" it > is a surprising behavior though. Yeah, it's a strange result, and possibly a sign that the syntax for Eshell conditionals wasn't the ideal way to do things. But it is what it is now, and hopefully there are ways to make it less surprising without making a major incompatible change to syntax. > BTW, a slightly related question if I may: A further diversion of > lisp-iness, I do not suppose there is a way to do a "return"? In bash, > the ability to "return" from sourced bash scripts or functions allows us > to deal with errors at the beginning, then process the main logic. I think this is related to a TODO in the Eshell manual to add a Bash-like "function" command, which would let you write whole functions in Eshell command form. I've also thought about the idea of adding syntax in Eshell so you can write stuff in Lisp forms but then go back out to writing command forms. Something like: (defun some-function () (do-stuff) ($ "echo $foobar") ;; Invoke an Eshell command. ) That might be tricky to get all the plumbing working though.