[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gzip: zfgrep fails to pass 2nd '-e' as an option, passes it as a file
From: |
Paul Eggert |
Subject: |
gzip: zfgrep fails to pass 2nd '-e' as an option, passes it as a file |
Date: |
Fri, 29 Dec 2006 19:04:04 -0800 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Following up on <http://bugs.debian.org/367673>:
I installed the following patch upstream, to fix the problem in a
different way. This patch also fixes several other option-processing
issues. It should appear in gzip 1.3.10.
2006-12-29 Paul Eggert <address@hidden>
* zgrep.in: Rewrite to make the option processing more
compatible with GNU and POSIX grep. Assume POSIX shell
for more stuff, since we're already assuming that.
* Makefile.am (check-local): Check zgrep -iV.
--- zgrep.in 27 Dec 2006 08:00:43 -0000 1.7
+++ zgrep.in 30 Dec 2006 02:58:33 -0000
@@ -50,6 +50,7 @@ escape='
s/'\''/'\''\\'\'''\''/g
$s/X$/'\''/
'
+operands=
have_pat=0
files_with_matches=0
files_without_matches=0
@@ -58,34 +59,39 @@ with_filename=0
while test $# -ne 0; do
option=$1
+ shift
optarg=
- case $1 in
+ case $option in
(-[0123456789abcdhHiIKLlnoqrRsTuUvVwxyzZ]?*)
- option=$(expr "X$1" : 'X\(-.[0-9]*\)')
- arg2=-\'$(expr "X$1X" : 'X-.[0-9]*\(.*\)' | sed "$escape")
- shift
- eval "set X $arg2 "'${1+"$@"}';;
+ arg2=-\'$(expr "X${option}X" : 'X-.[0-9]*\(.*\)' | sed "$escape")
+ eval "set -- $arg2 "'${1+"$@"}'
+ option=$(expr "X$option" : 'X\(-.[0-9]*\)');;
(--binary-*=* | --[lm]a*=* | --reg*=*)
;;
(-[ABCDefm] | --binary-* | --file | --[lm]a* | --reg*)
have_optarg=1
- case ${2?"$1 option requires an argument"} in
+ case ${1?"$option option requires an argument"} in
(*\'*)
- optarg=" '"$(printf '%sX\n' "$2" | sed "$escape");;
+ optarg=" '"$(printf '%sX\n' "$1" | sed "$escape");;
(*)
- optarg=" '$2'";;
+ optarg=" '$1'";;
esac
shift;;
(--)
- shift
break;;
- (-*)
+ (-?*)
;;
(*)
- break;;
+ case $option in
+ (*\'*)
+ operands="$operands '"$(printf '%sX\n' "$option" | sed "$escape");;
+ (*)
+ operands="$operands '$option'";;
+ esac
+ ${POSIXLY_CORRECT+break}
+ continue;;
esac
- shift
case $option in
(-[drRzZ] | --di* | --exc* | --inc* | --rec* | --nu*)
@@ -122,6 +128,8 @@ while test $# -ne 0; do
grep="$grep $option$optarg"
done
+eval "set -- $operands "'${1+"$@"}'
+
if test $have_pat -eq 0; then
case ${1?"missing pattern; try \`$0 --help' for help"} in
(*\'*)
@@ -133,8 +141,7 @@ if test $have_pat -eq 0; then
fi
if test $# -eq 0; then
- set X -
- shift
+ set -- -
fi
exec 3>&1
--- Makefile.am 24 Dec 2006 04:14:57 -0000 1.18
+++ Makefile.am 30 Dec 2006 02:58:33 -0000
@@ -69,6 +69,7 @@ check-local: $(FILES_TO_CHECK) gzip.doc.
./zdiff gzip.doc gzip.doc.gz
./zdiff -c - gzip.doc <gzip.doc.gz
./zdiff -c gzip.doc.gz gzip.doc.gz
+ ./zgrep -iV >/dev/null
for file in $(FILES_TO_CHECK); do \
./gzip -cv -- "$$file" | ./gzip -d | cmp - "$$file" || exit; \
done