Thursday, July 01, 2021

Re: while do done

> On Mon, 28 Jun 2021 22:20:15 +1000
> Reuben ua Bríฤก <u5644051@anu.edu.au> wrote:
>
> you cant interrupt sh in
>
> while do done
>
> not that it matters.

> Date: Fri, 2 Jul 2021 09:07:41 +1000
> From: Stuart Longland <stuartl@longlandclan.id.au>

> oninterrupt() {
> echo "I was interrupted!"
> exit 0
> }
>
> trap oninterrupt INT
> while true; do
> # Do something
> sleep 10
> done

you CAN interrupt

while do sleep 0; done

there is no need for exit, and it doesnt fix

while do done

or

while :; do :; done

if your shell needs something to not do.

as an aside, using while do as a simple loop and putting

sometest && break

is a good way to NOT get tests wrong.

No comments:

Post a Comment