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 EF5E9158008 for ; Fri, 16 Jun 2023 04:25:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 68F7DE0990; Fri, 16 Jun 2023 04:25:52 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 274C0E0978 for ; Fri, 16 Jun 2023 04:25:52 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH] pypi.eclass: Do extglob reset unconditionally Date: Fri, 16 Jun 2023 06:25:45 +0200 Message-ID: <20230616042545.242303-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.41.0 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: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: c846b12e-7db7-497f-877d-ee95ccc5f51c X-Archives-Hash: 9a5ec96aa32fc13ebf97ac7aa781cf28 Change _pypi_normalize_name() to reset extglob unconditionally. This function is called only in two contexts: - inside a subshell, therefore making it unnecessary to restore the original extglob value, - in global scope, via _pypi_set_globals, where we know that extglob is not supposed to be set. This makes the code simpler. Signed-off-by: Michał Górny --- eclass/pypi.eclass | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass index 8a842c450ebc..594216a7fd96 100644 --- a/eclass/pypi.eclass +++ b/eclass/pypi.eclass @@ -70,14 +70,12 @@ _PYPI_ECLASS=1 # Internal normalization function, returns the result # via _PYPI_NORMALIZED_NAME variable. _pypi_normalize_name() { - local name=${1} - if shopt -p -q extglob; then - name=${name//+([._-])/_} - else - shopt -s extglob - name=${name//+([._-])/_} - shopt -u extglob - fi + # NB: it's fine to alter it unconditionally since this function is + # always called from a subshell or in global scope + # (via _pypi_set_globals) + shopt -s extglob + local name=${1//+([._-])/_} + shopt -u extglob _PYPI_NORMALIZED_NAME="${name,,}" } -- 2.41.0