GNU bug report logs - #59612
29.0.50; Eshell: The behavior of conditionals depends on whitespace

Previous Next

Package: emacs;

Reported by: Milan Zimmermann <milan.zimmermann <at> gmail.com>

Date: Sat, 26 Nov 2022 15:54:02 UTC

Severity: normal

Found in version 29.0.50

Full log


View this message in rfc822 format

From: Jim Porter <jporterbugs <at> gmail.com>
To: Milan Zimmermann <milan.zimmermann <at> gmail.com>
Cc: 59612 <at> debbugs.gnu.org
Subject: bug#59612: 29.0.50; Eshell: The behavior of conditionals depends on whitespace
Date: Sat, 26 Nov 2022 19:13:31 -0800
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.




This bug report was last modified 2 years and 246 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.