summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-04-04 23:52:49 -0700
committerJim Meyering <meyering@fb.com>2022-04-07 09:28:24 -0700
commitc99f320d5c0fd98fe88d9cea5407eb7ad9d50e8a (patch)
tree1908dc14d678b36407c6a30ffe287bae3946e912
parentd74a30d45c6834c8e9f87115197370fe86656d81 (diff)
downloadgzip-c99f320d5c0fd98fe88d9cea5407eb7ad9d50e8a.tar.gz
zgrep: port to POSIX sed
* 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.
-rw-r--r--zgrep.in15
1 files 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=$(