Received: from ncopa-desktop.lan (ti0056a400-2261.bb.online.no [85.167.111.220]) (Authenticated sender: ncopa@alpinelinux.org) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPSA id C82C17810D5; Fri, 1 Jul 2022 09:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alpinelinux.org; s=smtp; t=1656667287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WB3rp9ecfrbbyyx//IRz2rv6rEb5rC0+x2sRT0IgAuw=; b=vAOGwD8+6WjF7D6ndzUDyA3atFFYcc1VQ+OBV5SJeevvinMadQZT2qlMppIbDsgfxS4qaZ dyQPu6I0wmdBcR3DjUWDDDHPgbvG0c9vdUv/kk+nuQCTTw4gmwzgH4zgEuj5yKsDyIs/9g Wd8ubE+uM5MXXECzcbFN4HQE8Nb7ta8= Date: Fri, 1 Jul 2022 11:21:24 +0200 From: Natanael Copa To: "Daniel F. Dickinson" Cc: ~alpine/devel@lists.alpinelinux.org Subject: Re: Fixing shell script libraries like /lib/libalpine.sh Message-ID: <20220701112124.7cd30d2e@ncopa-desktop.lan> In-Reply-To: <4caa8c5f-7ebf-ad2f-0e92-29428785fe60@wildtechgarden.ca> References: <4caa8c5f-7ebf-ad2f-0e92-29428785fe60@wildtechgarden.ca> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-alpine-linux-musl) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, 30 Jun 2022 02:16:49 -0400 "Daniel F. Dickinson" wrote: > Hello, >=20 > I've noticed some issues with the Alpine shell script libraries (one > example below)[1] >=20 > I'm new to Alpine but not to Linux, *BSD, or (way back) Ultrix, and have > not (yet) dug into the Alpine code base and infrastructure. (Although I > have my 'notes-to-self' documentation[2] that I intend (RSN...) to > integrate into the Wiki and have published on my website). >=20 > My questions with respect to the issues mentioned are: >=20 > 1. Do you prefer the GitLab merge request interface or the mailing list > for patches?[3] gitlab. =20 > 2. If you are not already using tools like shellcheck / shellfmt and or > shell unit tests in your CI, do you have objections to such being added? as long as it does not=20 =20 > I'm hoping to spend some time fixing this type of issue as they result > in annoying hiccups when trying to automate setup-alpine, and I'd like > that to work well. I'm working on the testsuite to add tests to make sure setup-alpine works with an "answer file". > A final note: I've got some cloud-init image creation using Packer > that I soon intend to push to public repository, along with Terraform > usage of the same; is there interest in those here? I almost forgot; > what is the status the work on the 'tiny' cloud-init substitute or > other alternatives in Alpine? I intend to make some kind of tiny-cloud nocloud provider, which will be able to take some sort of cloud-init compatible config for unattended installs. > Regards, >=20 > Daniel >=20 >=20 > [1]: >=20 > # test the first argument against the remaining ones, return success > on a match > isin() { > =A0=A0 =A0local _a=3D$1 _b > =A0=A0 =A0shift > =A0=A0 =A0for _b; do > =A0=A0 =A0=A0=A0=A0 [ "$_a" =3D "$_b" ] && return 0 > =A0=A0 =A0done > =A0=A0 =A0return 1 > } >=20 > _b is never assigned a value. This is not true. for _b; do ... is equivalent to for _b in "$@"; do ... So `isin "$resp" busybox openntpd chrony none abort; do` will iterate over "busybox openntpd chrony none abort" and return 0 (success) if $resp is in the listed options or 1 (failure) otherwise. See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#t= ag_18_09_04_03 > This is why automating ntp setup fails > (specifically the following code in /sbin/setup-ntp) will never skip > the 'ask': >=20 > while [ $# -eq 0 ] && ! isin "$resp" busybox openntpd chrony none abort; = do > =A0=A0 =A0ask "Which NTP client to run? ('busybox', 'openntpd', 'chrony' = or > 'none')" chrony > done I believe there is other problem. (I noticed you filed a bug. I will have a look at it) -nc