On Fri, 02 Jul 2021 14:16:20 +1000, Reuben ua =?UTF-8?Q?Br=C3=AD=C4=A1?= wrote:

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

Actually, the following _can_ be interrupted:

    while :; do done

    while :; do :; done

The only problem is:

    while do done

which may not actually be valid syntax.

I checked some other bourne/korn-like shells:

dash:
    $ while do done
    sh: 1: Syntax error: "do" unexpected

AT&T ksh:
    $ while do done
    ksh: syntax error: `do' unexpected

bash:
    bash-5.1$ while do done
    bash: syntax error near unexpected token `do'

zsh:
    % while do done
    [CPU loop like OpenBSD ksh]

I think the proper fix here is to reject the empty while in OpenBSD's
sh/ksh.

 - todd

Reply via email to