SHA256
1
0
forked from pool/bzip2
bzip2/bzip2-1.0.6-bzgrep_return_value.patch
Martin Pluskal 1048df5ab7 Accepting request 381843 from home:kstreitova:branches:Archiving
- add bzip2-1.0.6-bzgrep_return_value.patch to fix bzgrep wrapper
  that always returns 0 as an exit code when grepping multiple
  archives [bsc#970260]

OBS-URL: https://build.opensuse.org/request/show/381843
OBS-URL: https://build.opensuse.org/package/show/Archiving/bzip2?expand=0&rev=57
2016-03-30 13:48:20 +00:00

28 lines
852 B
Diff

Index: bzip2-1.0.6/bzgrep
===================================================================
--- bzip2-1.0.6.orig/bzgrep
+++ bzip2-1.0.6/bzgrep
@@ -65,8 +65,20 @@ for i do
else
j=$(echo "$i" | sed 's/\\/&&/g;s/|/\\&/g;s/&/\\&/g')
j=`printf "%s" "$j" | tr '\n' ' '`
- bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|"
- r=$?
+ # A trick adapted from
+ # https://groups.google.com/forum/#!original/comp.unix.shell/x1345iu10eg/Nn1n-1r1uU0J
+ # that has the same effect as the following bash code:
+ # bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|"
+ # r=${PIPESTATUS[1]}
+ exec 3>&1
+ eval `
+ exec 4>&1 >&3 3>&-
+ {
+ bzip2 -cdfq "$i" 4>&-
+ } | {
+ $grep $opt "$pat" 4>&-; echo "r=$?;" >&4
+ } | sed "s|^|${j}:|"
+ `
fi
test "$r" -ne 0 && res="$r"
done