From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH] pypi.eclass: Do extglob reset unconditionally
Date: Fri, 16 Jun 2023 06:25:45 +0200 [thread overview]
Message-ID: <20230616042545.242303-1-mgorny@gentoo.org> (raw)
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
reply other threads:[~2023-06-16 4:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230616042545.242303-1-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox