diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2022-04-04 23:52:49 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2022-04-07 09:28:24 -0700 |
commit | c99f320d5c0fd98fe88d9cea5407eb7ad9d50e8a (patch) | |
tree | 1908dc14d678b36407c6a30ffe287bae3946e912 | |
parent | d74a30d45c6834c8e9f87115197370fe86656d81 (diff) | |
download | gzip-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.in | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -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=$( |