Received: from 7of9.schinagl.nl (7of9.connected.by.freedominter.net [185.238.129.13]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 371C27800FD for <~alpine/devel@lists.alpinelinux.org>; Wed, 27 Jul 2022 11:33:49 +0000 (UTC) Received: from [10.2.12.24] (unknown [10.2.12.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by 7of9.schinagl.nl (Postfix) with ESMTPSA id DA8D0185A3F5 for <~alpine/devel@lists.alpinelinux.org>; Wed, 27 Jul 2022 13:33:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=schinagl.nl; s=7of9; t=1658921628; bh=xkTzyfYHiBiku1ABZ6QfcGlO3/+y82cSja7acrX7jQg=; h=Date:Reply-To:Subject:To:References:From:In-Reply-To; b=hflFoCQoMRNp7Z2S7t+wcUJKHOmOU0JrFm1cQTvjrRqSrzvxPtR2MBhsUOCDF5hTr b6tt2RJuG5JtNjXoSO79HtqXemzruw+FbSBps7jrxijVj4RLIuQU0QfiD1OwhaxRXi kKxFmKC/WhFBT7NTUBiARdzckDztQAazNkYvkgv8= Message-ID: <5afc481f-00fa-176a-5210-f877c8a33a9e@schinagl.nl> Date: Wed, 27 Jul 2022 13:33:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Reply-To: oliver+list@schinagl.nl Subject: Re: Fixing shell script libraries like /lib/libalpine.sh Content-Language: nl To: ~alpine/devel@lists.alpinelinux.org References: <4caa8c5f-7ebf-ad2f-0e92-29428785fe60@wildtechgarden.ca> From: Olliver Schinagl In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 30-06-2022 09:07, Dominique Martinet wrote: > Daniel F. Dickinson wrote on Thu, Jun 30, 2022 at 02:16:49AM -0400: >> # test the first argument against the remaining ones, return success on >> a match >> isin() { >>     local _a=$1 _b >>     shift >>     for _b; do >>         [ "$_a" = "$_b" ] && return 0 >>     done >>     return 1 >> } >> >> _b is never assigned a value. This is why automating ntp setup fails >> (specifically the following code in /sbin/setup-ntp) will never skip the >> 'ask': > > `for _b; do` is identical to `for _b in "$@"; do` and assigns the values > properly. Wouldn't the identical variant not be preferred in code? It reads easier and is _obvious_ what happens. Writing code happens rarly, that we shouldn't try to optimize it to be as short as possible; reading code however, we do often, so having it more readable is usually for the better ... Also, 'hidden' features/side effects tend to be never nice, because what you know, does not mean others know as well ;) (we you, not you-you) Olliver > The function works properly for me. > > setup-ntp also works for me, what exactly are you experiencing or > expecting? > > -- > Asmadeus | Dominique Martinet