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.
>

vk4msl-bne$ cat test.sh
#!/bin/sh

oninterrupt() {
echo "I was interrupted!"
exit 0
}

trap oninterrupt INT
while true; do
# Do something
sleep 10
done
vk4msl-bne$ sh test.sh
^CI was interrupted!
vk4msl-bne$ uname -a
OpenBSD vk4msl-bne.dmz.longlandclan.id.au 6.9 GENERIC#0 amd64


--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

No comments:

Post a Comment