From 953e93ec52c660d5c3ef91f8ab463aa1be965b38 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 14 Aug 2012 20:43:16 -0700 Subject: [PATCH 1/1] 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. --- zgrep.in | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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*) -- 2.30.2