On Sun, Jul 04 2021, Todd C. Miller <[email protected]> wrote:
> On Sun, 04 Jul 2021 23:25:25 +0200, Alexander Hall wrote:
>
>> The "... do done" variant has been frequently used by me, and seems to appear
>> at least three times in install.sub, so if this goes in, please scan the scr
>> ipts in our tree first, at least for trivial cases.
>
> Fair enough, let's just require a non-empty expression but still
> allow an empty loop body.
> Index: bin/ksh/syn.c
> ===================================================================
> RCS file: /cvs/src/bin/ksh/syn.c,v
> retrieving revision 1.39
> diff -u -p -u -r1.39 syn.c
> --- bin/ksh/syn.c 24 Apr 2018 08:25:16 -0000 1.39
> +++ bin/ksh/syn.c 4 Jul 2021 22:21:39 -0000
> @@ -331,6 +331,8 @@ get_command(int cf)
> nesting_push(&old_nesting, c);
> t = newtp((c == WHILE) ? TWHILE : TUNTIL);
> t->left = c_list(true);
> + if (t->left == NULL)
> + syntaxerr(NULL);
> t->right = dogroup();
> nesting_pop(&old_nesting);
> break;
>
LGTM as a first step, ok jca@
> It would be a good idea to call this out
> as a portability issue in the ksh manual but that can be done
> separately.
I'd prefer to fix the odd uses we have in tree and end up with your
initial diff in a third step.
Here are the three cases pointed out by halex@, mechanical diff.
ok? / Todd, feel free to pick it up with my ok.
Index: install.sub
===================================================================
RCS file: /d/cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1165
diff -u -p -p -u -r1.1165 install.sub
--- install.sub 3 Jun 2021 15:05:55 -0000 1.1165
+++ install.sub 5 Jul 2021 13:02:37 -0000
@@ -223,7 +223,7 @@ tmpdir() {
unique_filename() {
local _fn=$1 _ufn
- while _ufn=${_fn}.$RANDOM && [[ -e $_ufn ]]; do done
+ while _ufn=${_fn}.$RANDOM && [[ -e $_ufn ]]; do :; done
print -- "$_ufn"
}
@@ -530,7 +530,7 @@ configure_disk() {
# Acquire lock.
lock() {
- while ! mkdir /tmp/i/lock 2>/dev/null && sleep .1; do done
+ while ! mkdir /tmp/i/lock 2>/dev/null && sleep .1; do :; done
}
# Release lock.
@@ -765,7 +765,7 @@ _ask() {
ask() {
# Prompt again in case the dmesg listener detected a change.
- while ! _ask "$1" "$2"; do done
+ while ! _ask "$1" "$2"; do :; done
log_answers "$1" "$resp"
}
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE