47 lines
1.3 KiB
Diff
47 lines
1.3 KiB
Diff
From c99f320d5c0fd98fe88d9cea5407eb7ad9d50e8a Mon Sep 17 00:00:00 2001
|
||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||
Date: Mon, 4 Apr 2022 23:52:49 -0700
|
||
Subject: zgrep: port to POSIX sed
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
* zgrep.in (res): When escaping the file name do not rely on GNU
|
||
sed’s extension to POSIX with respect to s/.../\n/. Instead, use
|
||
features that should also work with AIX and/or Solaris sed. This is
|
||
simpler anyway, and would have prevented the recently-fixed bug.
|
||
---
|
||
zgrep.in | 15 ++++-----------
|
||
1 file changed, 4 insertions(+), 11 deletions(-)
|
||
|
||
diff --git a/zgrep.in b/zgrep.in
|
||
index bdf7da2..6a16dd1 100644
|
||
--- a/zgrep.in
|
||
+++ b/zgrep.in
|
||
@@ -220,18 +220,11 @@ do
|
||
case $i in
|
||
(*'
|
||
'* | *'&'* | *'\'* | *'|'*)
|
||
- i=$(printf '%s\n' "$i" |
|
||
- sed '
|
||
- :start
|
||
- $!{
|
||
- N
|
||
- b start
|
||
- }
|
||
- s/[&\|]/\\&/g
|
||
- s/\n/\\n/g
|
||
- ');;
|
||
+ icolon=$(printf '%s\n' "$i:" |
|
||
+ sed -e 's/[&\|]/\\&/g' -e '$!s/$/\\/');;
|
||
+ (*) icolon="$i:";;
|
||
esac
|
||
- sed_script="s|^|$i:|"
|
||
+ sed_script="s|^|$icolon|"
|
||
|
||
# Fail if grep or sed fails.
|
||
r=$(
|
||
--
|
||
cgit v1.1
|
||
|