bug-gzip
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: zgrep -<NUM> doesn't work if <NUM> is two digits or greater


From: Paul Eggert
Subject: Re: zgrep -<NUM> doesn't work if <NUM> is two digits or greater
Date: Tue, 14 Aug 2012 20:48:55 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0

On 08/07/2012 10:24 AM, Jim Meyering wrote:
> +    if expr "X$option" : 'X-[0-9]\+$' > /dev/null; then

This part of the patch is not portable, since '\+' is
a GNU extension, and its behavior isn't specified by POSIX.

To fix this I installed the following zgrep.in patch.
This diff is relative to the zgrep.in before the current
series of patches, since that makes it easier to review.
The basic idea is to avoid the use of expr here, and
rely just on shell pattern-matching; that's more efficient
anyway.

--- a/zgrep.in
+++ b/zgrep.in
@@ -65,7 +65,7 @@ while test $# -ne 0; do
   optarg=
 
   case $option in
-  (-[0123456789EFGHIKLPRTUVZabchilnoqrsuvwxyz]?*)
+  (-[0123456789EFGHIKLPRTUVZabchilnoqrsuvwxyz]*[!0123456789]*)
     arg2=-\'$(expr "X$option" : 'X-.[0-9]*\(.*\)' | sed "$escape")
     eval "set -- $arg2 "'${1+"$@"}'
     option=$(expr "X$option" : 'X\(-.[0-9]*\)');;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]