Understand `--' to end processing of command options.
This means one search for a string starting with a dash. Fix also filenames starting with a dash. Close PR #3349
This commit is contained in:
parent
e5e3bb8d08
commit
2e387c4923
@ -26,7 +26,7 @@
|
|||||||
#
|
#
|
||||||
# zgrep - search possibly compressed files for a regular expression
|
# zgrep - search possibly compressed files for a regular expression
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id: zgrep.getopt,v 1.4 1997/02/22 15:46:11 peter Exp $
|
||||||
|
|
||||||
|
|
||||||
PATH=/bin:/usr/bin:$PATH; export PATH
|
PATH=/bin:/usr/bin:$PATH; export PATH
|
||||||
@ -67,7 +67,7 @@ files="$@"
|
|||||||
# no shell loop neccessary for option -q or -h
|
# no shell loop neccessary for option -q or -h
|
||||||
# and a single file or reading from stdin
|
# and a single file or reading from stdin
|
||||||
case "$header"X"$#" in
|
case "$header"X"$#" in
|
||||||
-h*|-q*|X0|X1) $gzip $gzipopt $files | $grep $grepopt $pattern
|
-h*|-q*|X0|X1) $gzip $gzipopt -- $files | $grep $grepopt -- $pattern
|
||||||
exit $?;;
|
exit $?;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -76,13 +76,13 @@ exit=1
|
|||||||
for f in $files
|
for f in $files
|
||||||
do
|
do
|
||||||
case "$line" in
|
case "$line" in
|
||||||
-l|-L) if $gzip $gzipopt $f |
|
-l|-L) if $gzip $gzipopt -- $f |
|
||||||
$grep $grepopt $pattern >/dev/null
|
$grep $grepopt -- $pattern >/dev/null
|
||||||
then
|
then
|
||||||
echo $f
|
echo $f
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) $gzip $gzipopt $f | $grep $grepopt $pattern |
|
*) $gzip $gzipopt -- $f | $grep $grepopt -- $pattern |
|
||||||
sed "s%^%${f}:%";;
|
sed "s%^%${f}:%";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user