commit: 69e5b3079697d03ed38422327f917f1633c64a02
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jun 17 22:34:27 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun 17 23:40:47 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=69e5b307
emerge-webrsync: simplify the do_tar() function
Simplify the do_tar() function by having the case statement assume
responsibility for dispatching the decompression command, and by having
it be the first stage of the pipeline. Further, replace the buggy
PIPESTATUS handling (sensitive to the value of IFS) by enabling the
pipefail shell option in function scope. Doing so is acceptable, given a
target of bash >=4.4.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/emerge-webrsync | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 93b1674a86..1f4830e795 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -161,19 +161,18 @@ handle_pgp_setup() {
}
do_tar() {
- local file=$1
- local decompressor
- shift
-
- case ${file} in
- *.xz) decompressor="xzcat" ;;
- *.bz2) decompressor="bzcat" ;;
- *.gz) decompressor="zcat" ;;
- *) decompressor="cat" ;;
- esac
- ${decompressor} "${file}" | tar "$@"
- _pipestatus=${PIPESTATUS[*]}
- [[ ${_pipestatus// /} -eq 0 ]]
+ local -
+
+ shopt -o -s pipefail
+ case $1 in
+ *.xz) xzcat "$1" ;;
+ *.bz2) bzcat "$1" ;;
+ *.gz) zcat "$1" ;;
+ *) cat "$1" ;;
+ esac | {
+ shift
+ tar "$@"
+ }
}
get_utc_date_in_seconds() {