From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D7461158008 for ; Tue, 13 Jun 2023 09:08:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 80FECE09DD; Tue, 13 Jun 2023 09:08:08 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 46BB8E09D9 for ; Tue, 13 Jun 2023 09:08:08 +0000 (UTC) From: Ulrich Mueller To: =?utf-8?B?TWljaGHFgiBHw7Nybnk=?= Cc: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] [PATCH 7/7] pypi.eclass: Avoid subshell for extglob setting In-Reply-To: <20230613064742.413335-8-mgorny@gentoo.org> (=?utf-8?Q?=22Mic?= =?utf-8?Q?ha=C5=82_G=C3=B3rny=22's?= message of "Tue, 13 Jun 2023 08:45:07 +0200") References: <20230613064742.413335-1-mgorny@gentoo.org> <20230613064742.413335-8-mgorny@gentoo.org> Date: Tue, 13 Jun 2023 11:07:57 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Archives-Salt: 51747bcc-e10d-4555-90e4-995e2639d7c2 X-Archives-Hash: 3e28d050d8319322447335a87272fb5d --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> On Tue, 13 Jun 2023, Micha=C5=82 G=C3=B3rny wrote: > _pypi_normalize_name() { > local name=3D${1} > - local shopt_save=3D$(shopt -p extglob) > - shopt -s extglob > + local prev_extglob=3D-s > + if ! shopt -p extglob >/dev/null; then > + prev_extglob=3D-u > + shopt -s extglob > + fi > name=3D${name//+([._-])/_} > - ${shopt_save} > + shopt "${prev_extglob}" extglob > _PYPI_NORMALIZED_NAME=3D"${name,,}" > } In principle you could also do something like this: if shopt -pq extglob; then name=3D${name//+([._-])/_} else shopt -s extglob name=3D${name//+([._-])/_} shopt -u extglob fi It duplicates one line of code, but saves a variable and IMHO the code would be easier to understand. Also, with the -q option no output redirection is needed. Ulrich --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmSIMe0PHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4uPbQIALwHoHoDWeWgDj2nlYXT1Ytvcyo5toaVe9Wg 7R9sTq3UTMBIMdKXUQwwePIRI8zJE/xrUcDNUq0x8u5jNXg/WfH+dGoxo1TGNMiM lWicXPhvdTK+KM7cyVvtzkBVaJZDrW5HzAktCHGj3t7zDGFh7lN/Aih9CeJWD62s FdGnXuik8T19spcfJ5lxhCfHDCG/W6S9ip9T4LhaEC6VYybw0aNMFnR6akJcTI+h H/IyL824imc84wetCiw7euZFeduy2adeLF4g+ibJ87vRUVw8w6+Ct+bXtZXfKJJC ia6f5v18vXoImULnSZjl1H+pmkJ8iWKEu8Cdsz7YaRi7bHLZbP8= =y9l0 -----END PGP SIGNATURE----- --=-=-=--