Exactly my point. Even if the circumstances were contrived, I think it would 
good to fix it just for the sake of correctness.

The issue is actually a pattern I found not only in /etc/netstart but also in 
/etc/rc. (( )) cannot deal with an empty result yet it sometimes includes calls 
to sysctl which apparently can return an empty string in some cases.

So options are:

1. ensure that sysctl always returns a number where it is expected
2. work around the issue by using /bin/[ in place of or in addition to, the 
arithmetic expression (depending on the expression being tested), so that 
whatever returns empty string can be tested instead of blowing up.

P.S. To answer another poster's question, I didn't get any error from sysctl. I 
tried it manually at the prompt and I got back nothing.

Hope that helps.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, October 8th, 2021 at 1:41 PM, Philip Guenther <guent...@gmail.com> 
wrote:

> On Fri, Oct 8, 2021 at 8:57 AM Theo de Raadt <dera...@openbsd.org> wrote:
>
>> Philip Guenther <guent...@gmail.com> wrote:
>>
>>> On Thu, Oct 7, 2021 at 5:57 PM bm1les <bm1...@protonmail.com> wrote:
>>>
>>> > --- netstart 2 Sep 2021 19:38:20 -0000 1.216
>>> > +++ netstart 8 Oct 2021 02:43:30 -0000
>>> > @@ -365,7 +365,7 @@ ifmstart "tun tap gif etherip gre egre p
>>> > if [[ $ip6kernel == YES ]]; then
>>> > # Ensure IPv6 Duplicate Address Detection (DAD) is completed.
>>> > count=0
>>> > - while ((count++ < 10 && $(sysctl -n net.inet6.ip6.dad_pending) !=
>>> > 0)); do
>>> > + while ((count++ < 10 && "$(sysctl -n net.inet6.ip6.dad_pending)"
>>> > != 0)); do
>>> > sleep 1
>>> > done
>>> > fi
>>> >
>>>
>>> I can't figure out what problem you think this could solve. Can you
>>> explain the circumstances under which those quotes could make a difference?
>>
>> Not the OP's issue, but I think a kernels compiled without option INET6
>> will return an errno, and I cannot tell if sysctl prints out an error message
>> or converts to "", the empty string, which would conceivably mis-parse.
>
> AFAICT, an empty quoted string there results in the exact same error. As I 
> wrote off-list to the original submitter:
>
>> Can you be clearer about how the quoting makes the result any better when 
>> run under bsd.rd? Doesn't it fail in the same way? Testing with 'echo' 
>> instead would seem to indicate so:
>> : bleys; (( 1 < 10 && $(echo) != 0 )); echo $?
>> /bin/ksh: 1 < 10 && != 0 : unexpected `!='
>> 2
>> : bleys; (( 1 < 10 && $(echo -n) != 0 )); echo $?
>> /bin/ksh: 1 < 10 && != 0 : unexpected `!='
>> 2
>> : bleys; (( 1 < 10 && "$(echo)" != 0 )); echo $?
>> /bin/ksh: 1 < 10 && != 0 : unexpected `!='
>> 2
>> : bleys; (( 1 < 10 && "$(echo -n)" != 0 )); echo $?
>> /bin/ksh: 1 < 10 && != 0 : unexpected `!='
>> 2
>> : bleys;
>
> Philip

Reply via email to