help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: break out of nested `if`


From: Andreas Kusalananda Kähäri
Subject: Re: break out of nested `if`
Date: Sun, 24 May 2020 21:03:22 +0200

Please show the use case.  Also mention if you know of another common
language that provide this feature.

On Sun, May 24, 2020 at 08:27:26AM -0500, Peng Yu wrote:
> Hi,
> 
> `break n` can break out of nested `for`. But sometimes it would be
> convenient to break from nested `if`, which does not seem to be an
> available feature in bash.
> 
> One walkaround is to put the nested `if` in a function and use return
> to break from the nested if. But this is not very convenient, as an
> extra function must be defined.
> 
> Is there a better walkaround to this problem? Thanks.
> 
> -- 
> Regards,
> Peng

-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]