public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] pypi.eclass: Do extglob reset unconditionally
@ 2023-06-16  4:25 Michał Górny
  0 siblings, 0 replies; only message in thread
From: Michał Górny @ 2023-06-16  4:25 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

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 <mgorny@gentoo.org>
---
 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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-16  4:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-16  4:25 [gentoo-dev] [PATCH] pypi.eclass: Do extglob reset unconditionally Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox