Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: infinite loop that is possible to quit



Emanuel Berg wrote on Tue, Dec 01, 2020 at 02:50:10 +0100:
> How do I do an infinite loop that runs something, but it will
> still be possible to quit the whole thing?
> 
> The best thing I've come up with is
> 
> while true; do
>   # run program
>   sleep 1
> done
> 
> Then do, say, q to exit the program, and C-c during the sleep
> period to quit the loop!
> 
> Is this good or bad?

I'd spell it like this:

    while run program && sleep 1; do done

Or use the Linux version of watch(1) (not to be confused with the FreeBSD tool
of the same name).






Messages sorted by: Reverse Date, Date, Thread, Author