From: Paul Eggert Date: Wed, 15 Aug 2012 03:43:16 +0000 (-0700) Subject: zgrep: do not assume GNU expr X-Git-Tag: v1.6~27 X-Git-Url: https://git.gag.com/?p=debian%2Fgzip;a=commitdiff_plain;h=953e93ec52c660d5c3ef91f8ab463aa1be965b38 zgrep: do not assume GNU expr * zgrep.in: Do not assume '\+' has the GNU behavior in the BRE given to 'expr', as POSIX does not guarantee that. Come to think of it, use a shell pattern rather than 'expr', as this is more efficient. --- diff --git a/zgrep.in b/zgrep.in index abc5847..f878acf 100644 --- a/zgrep.in +++ b/zgrep.in @@ -65,14 +65,10 @@ while test $# -ne 0; do optarg= case $option in - (-[0123456789EFGHIKLPRTUVZabchilnoqrsuvwxyz]?*) - if expr "X$option" : 'X-[0-9]\+$' > /dev/null; then - : # Let a multi-digit, digit-only option like -10 fall through. - else - arg2=-\'$(expr "X$option" : 'X-.[0-9]*\(.*\)' | sed "$escape") - eval "set -- $arg2 "'${1+"$@"}' - option=$(expr "X$option" : 'X\(-.[0-9]*\)') - fi;; + (-[0123456789EFGHIKLPRTUVZabchilnoqrsuvwxyz]*[!0123456789]*) + arg2=-\'$(expr "X$option" : 'X-.[0-9]*\(.*\)' | sed "$escape") + eval "set -- $arg2 "'${1+"$@"}' + option=$(expr "X$option" : 'X\(-.[0-9]*\)');; (--binary-*=* | --[lm]a*=* | --reg*=*) ;; (-[ABCDXdefm] | binary-* | --file | --[lm]a* | --reg*)