|
Lines 21-31
Link Here
|
| 21 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
21 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 22 |
# 02111-1307, USA. |
22 |
# 02111-1307, USA. |
| 23 |
|
23 |
|
| 24 |
# Improve error handling, this is supported by bash but not all the other |
24 |
# Improve error handling, this is supported by bash but not all the other |
| 25 |
# shells so we hide the possible error: |
25 |
# shells so we hide the possible error: |
| 26 |
set -o pipefail > /dev/null 2> /dev/null |
26 |
if [ -n $BASH_VERSION ] |
|
|
27 |
then |
| 28 |
set -o pipefail &> /dev/null |
| 29 |
fi |
| 27 |
|
30 |
|
| 28 |
prog=`echo "$0" | sed 's|.*/||'` |
31 |
prog=`echo "$0" | sed 's|.*/||'` |
| 29 |
case "$prog" in |
32 |
case "$prog" in |
| 30 |
*egrep) grep=${EGREP-egrep} ;; |
33 |
*egrep) grep=${EGREP-egrep} ;; |
| 31 |
*fgrep) grep=${FGREP-fgrep} ;; |
34 |
*fgrep) grep=${FGREP-fgrep} ;; |
|
Lines 91-113
Link Here
|
| 91 |
lzma -dc | $grep $opt "$pat" |
94 |
lzma -dc | $grep $opt "$pat" |
| 92 |
exit $? |
95 |
exit $? |
| 93 |
fi |
96 |
fi |
| 94 |
|
97 |
|
| 95 |
res=0 |
98 |
res=0 |
| 96 |
trap break SIGPIPE |
99 |
trap break PIPE |
| 97 |
for i do |
100 |
for i do |
| 98 |
lzma -dc "$i" | |
101 |
lzma -dc "$i" | |
| 99 |
if test $files_with_matches -eq 1; then |
102 |
if test $files_with_matches -eq 1; then |
| 100 |
$grep $opt "$pat" > /dev/null && printf "%s\n" "$i" |
103 |
$grep $opt "$pat" > /dev/null && printf "%s\n" "$i" |
| 101 |
elif test $files_without_matches -eq 1; then |
104 |
elif test $files_without_matches -eq 1; then |
| 102 |
$grep $opt "$pat" > /dev/null || printf "%s\n" "$i" |
105 |
$grep $opt "$pat" > /dev/null || printf "%s\n" "$i" |
| 103 |
elif test $with_filename -eq 0 && { test $# -eq 1 || test $no_filename -eq 1; }; then |
106 |
elif test $with_filename -eq 0 && { test $# -eq 1 || test $no_filename -eq 1; }; then |
| 104 |
$grep $opt "$pat" |
107 |
$grep $opt "$pat" |
| 105 |
else |
108 |
else |
| 106 |
i=${i//\\/\\\\} |
109 |
i=$(echo "$i" | sed -e 's,\\,\\\\,g' -e 's,|,\\|,g' -e 's,&,\\&,g') |
| 107 |
i=${i//|/\\|} |
|
|
| 108 |
i=${i//&/\\&} |
| 109 |
i=`printf "%s" "$i" | tr '\n' ' '` |
110 |
i=`printf "%s" "$i" | tr '\n' ' '` |
| 110 |
if test $with_filename -eq 1; then |
111 |
if test $with_filename -eq 1; then |
| 111 |
sed_script="s|^[^:]*:|${i}:|" |
112 |
sed_script="s|^[^:]*:|${i}:|" |
| 112 |
else |
113 |
else |
| 113 |
sed_script="s|^|${i}:|" |
114 |
sed_script="s|^|${i}:|" |
|
Lines 117-123
Link Here
|
| 117 |
r=$? |
118 |
r=$? |
| 118 |
test $res -lt $r && res=$r |
119 |
test $res -lt $r && res=$r |
| 119 |
# SIGPIPE + 128 |
120 |
# SIGPIPE + 128 |
| 120 |
test "$r" -eq 141 && exit $res |
121 |
test "$r" -eq 141 && exit $res |
| 121 |
done |
122 |
done |
| 122 |
trap - SIGPIPE |
123 |
trap - PIPE |
| 123 |
exit $res |
124 |
exit $res |