GNU bug report logs - #72952
30.0.90; Want way to break out of Eshell for loop

Previous Next

Package: emacs;

Reported by: Sean Whitton <spwhitton <at> spwhitton.name>

Date: Mon, 2 Sep 2024 09:04:01 UTC

Severity: normal

Found in version 30.0.90

To reply to this bug, email your comments to 72952 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to jporterbugs <at> gmail.com, bug-gnu-emacs <at> gnu.org:
bug#72952; Package emacs. (Mon, 02 Sep 2024 09:04:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sean Whitton <spwhitton <at> spwhitton.name>:
New bug report received and forwarded. Copy sent to jporterbugs <at> gmail.com, bug-gnu-emacs <at> gnu.org. (Mon, 02 Sep 2024 09:04:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.90; Want way to break out of Eshell for loop
Date: Mon, 02 Sep 2024 09:26:55 +0100
X-debbugs-cc: jporterbugs <at> gmail.com

I am trying to run a series of tests like this:

    % for test in tests/tests/tagupl* { tests/using-intree $test }

I want the command to give up as soon as one of the tests fails.  But I
don't think there is any way to break out of the loop?  In POSIX sh, you
could use 'break'.

Thanks.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72952; Package emacs. (Mon, 09 Sep 2024 01:02:01 GMT) Full text and rfc822 format available.

Message #8 received at 72952 <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Sean Whitton <spwhitton <at> spwhitton.name>, 72952 <at> debbugs.gnu.org
Subject: Re: bug#72952: 30.0.90; Want way to break out of Eshell for loop
Date: Sun, 8 Sep 2024 17:59:49 -0700
On 9/2/2024 1:26 AM, Sean Whitton wrote:
> X-debbugs-cc: jporterbugs <at> gmail.com
> 
> I am trying to run a series of tests like this:
> 
>      % for test in tests/tests/tagupl* { tests/using-intree $test }
> 
> I want the command to give up as soon as one of the tests fails.  But I
> don't think there is any way to break out of the loop?  In POSIX sh, you
> could use 'break'.

I actually have a patch sitting in my pile of branches that does this, 
but it needs a fair bit more work to get right. The main thing it needs 
is to keep 'break' from bubbling up too far (e.g. if you run an Eshell 
script from inside a loop, 'break' at the top level of the script 
shouldn't break out of the parent loop).

Another way to do something like this would be to embrace the Lispy-ness 
of Eshell and add a command-form for 'throw' and 'catch'. Something like:

  catch my-tag {
    for i in *.el {
     do-stuff
     if something-or-other { throw my-tag }
    }
  }

Or even support both 'throw'/'catch' *and* 'break'...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72952; Package emacs. (Thu, 12 Sep 2024 10:05:01 GMT) Full text and rfc822 format available.

Message #11 received at 72952 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: 72952 <at> debbugs.gnu.org
Subject: Re: bug#72952: 30.0.90; Want way to break out of Eshell for loop
Date: Thu, 12 Sep 2024 11:04:06 +0100
Hello,

On Sun 08 Sep 2024 at 05:59pm -07, Jim Porter wrote:

> On 9/2/2024 1:26 AM, Sean Whitton wrote:
>> X-debbugs-cc: jporterbugs <at> gmail.com
>> I am trying to run a series of tests like this:
>>      % for test in tests/tests/tagupl* { tests/using-intree $test }
>> I want the command to give up as soon as one of the tests fails.  But I
>> don't think there is any way to break out of the loop?  In POSIX sh, you
>> could use 'break'.
>
> I actually have a patch sitting in my pile of branches that does this, but it
> needs a fair bit more work to get right. The main thing it needs is to keep
> 'break' from bubbling up too far (e.g. if you run an Eshell script from inside
> a loop, 'break' at the top level of the script shouldn't break out of the
> parent loop).
>
> Another way to do something like this would be to embrace the Lispy-ness of
> Eshell and add a command-form for 'throw' and 'catch'. Something like:
>
>   catch my-tag {
>     for i in *.el {
>      do-stuff
>      if something-or-other { throw my-tag }
>     }
>   }
>
> Or even support both 'throw'/'catch' *and* 'break'...

Heh.  throw/catch seems like overkill to me but supporting both would be
cool!

-- 
Sean Whitton




This bug report was last modified 274 days ago.

Previous Next


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