public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] texlive-module.eclass: use pipestatus
@ 2024-12-11  8:57 Florian Schmaus
  2024-12-11 10:54 ` Ulrich Müller
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Schmaus @ 2024-12-11  8:57 UTC (permalink / raw
  To: gentoo-dev; +Cc: tex, Florian Schmaus

Signed-off-by: Florian Schmaus <flow@gentoo.org>
---
 eclass/texlive-module.eclass | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index f8b6f0858cd6..4ba507d4fd70 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -79,7 +79,7 @@ esac
 if [[ -z ${_TEXLIVE_MODULE_ECLASS} ]]; then
 _TEXLIVE_MODULE_ECLASS=1
 
-inherit texlive-common
+inherit eapi9-pipestatus texlive-common
 
 HOMEPAGE="https://www.tug.org/texlive/"
 
@@ -537,16 +537,15 @@ texlive-module_src_install() {
 				grep_expressions+=(-e "/${f//./\\.}\$")
 			done
 
+			local status
+			# "success-status aware grep", returning exit status 0 instead of 1.
+			sgrep() { grep "$@"; return "$(( $? <= 1 ? 0 : $? ))"; }
 			ebegin "Installing man pages"
 			find texmf-dist/doc/man -type f -name '*.[0-9n]' -print |
-				grep -v "${grep_expressions[@]}" |
+				sgrep -v "${grep_expressions[@]}" |
 				xargs -d '\n' --no-run-if-empty nonfatal doman
-			local pipestatus="${PIPESTATUS[*]}"
-			# The grep in the middle of the pipe may return 1 in case
-			# everything from the input is dropped.
-			# See https://bugs.gentoo.org/931994
-			[[ ${pipestatus} == "0 "[01]" 0" ]]
-			eend $? || die "error installing man pages (pipestatus: ${pipestatus})"
+			status=$(pipestatus -v)
+			eend $? || die "error installing man pages (PIPESTATUS: ${status})"
 
 			# Delete all man pages under texmf-dist/doc/man
 			find texmf-dist/doc/man -type f -name '*.[0-9n]' -delete ||
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-dev] [PATCH] texlive-module.eclass: use pipestatus
  2024-12-11  8:57 [gentoo-dev] [PATCH] texlive-module.eclass: use pipestatus Florian Schmaus
@ 2024-12-11 10:54 ` Ulrich Müller
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Müller @ 2024-12-11 10:54 UTC (permalink / raw
  To: Florian Schmaus; +Cc: gentoo-dev, tex

[-- Attachment #1: Type: text/plain, Size: 1568 bytes --]

>>>>> On Wed, 11 Dec 2024, Florian Schmaus wrote:

> --- a/eclass/texlive-module.eclass
> +++ b/eclass/texlive-module.eclass
> @@ -79,7 +79,7 @@ esac
>  if [[ -z ${_TEXLIVE_MODULE_ECLASS} ]]; then
>  _TEXLIVE_MODULE_ECLASS=1
>  
> -inherit texlive-common
> +inherit eapi9-pipestatus texlive-common
>  
>  HOMEPAGE="https://www.tug.org/texlive/"
>  
> @@ -537,16 +537,15 @@ texlive-module_src_install() {
>  				grep_expressions+=(-e "/${f//./\\.}\$")
>  			done
>  
> +			local status
> +			# "success-status aware grep", returning exit status 0 instead of 1.
> +			sgrep() { grep "$@"; return "$(( $? <= 1 ? 0 : $? ))"; }

"sgrep" is rather generic as a function name and prone to name clashes.
I suggest "_tl_grep" instead.

>  			ebegin "Installing man pages"
>  			find texmf-dist/doc/man -type f -name '*.[0-9n]' -print |
> -				grep -v "${grep_expressions[@]}" |
> +				sgrep -v "${grep_expressions[@]}" |
>  				xargs -d '\n' --no-run-if-empty nonfatal doman
> -			local pipestatus="${PIPESTATUS[*]}"
> -			# The grep in the middle of the pipe may return 1 in case
> -			# everything from the input is dropped.
> -			# See https://bugs.gentoo.org/931994
> -			[[ ${pipestatus} == "0 "[01]" 0" ]]
> -			eend $? || die "error installing man pages (pipestatus: ${pipestatus})"
> +			status=$(pipestatus -v)
> +			eend $? || die "error installing man pages (PIPESTATUS: ${status})"
>  
>  			# Delete all man pages under texmf-dist/doc/man
>  			find texmf-dist/doc/man -type f -name '*.[0-9n]' -delete ||

Otherwise LGTM.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-11 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11  8:57 [gentoo-dev] [PATCH] texlive-module.eclass: use pipestatus Florian Schmaus
2024-12-11 10:54 ` Ulrich Müller

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