Friday, July 02, 2021

Re: while do done

> Date: Fri, 2 Jul 2021 11:17:20 -0600
> From: "Todd C. Miller" <Todd.Miller@sudo.ws>

> Actually, the following _can_ be interrupted:
>
> while :; do done
>
> while :; do :; done

oops. its been so long i completely forgot.

> The only problem is:
>
> while do done
>
> which may not actually be valid syntax.

src/bin/ksh/NOTES says:

- pdksh accepts empty command lists for while and for statements,
while at&t ksh (and sh) don't. Eg., pdksh likes
while false ; do done
but ksh88 doesn't like it.

if only i had never read that file! i would have happily stuck to

while :; do

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

maybe not the only way, but it would work and is completely reasonable.

No comments:

Post a Comment