diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2022-04-04 23:52:49 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2022-04-07 09:28:24 -0700 |
commit | 0e2d07fc2c4393cfb9dbab580d0bee4525b9c9b3 (patch) | |
tree | 92f29fdc7e99aa614faa1c91b150a6bf15491667 | |
parent | 6543c09c6ecfb1630085d440b76511953bc5a2cb (diff) | |
download | gzip-0e2d07fc2c4393cfb9dbab580d0bee4525b9c9b3.tar.gz |
gzexe: optimize out a grep
* gzexe.in: Avoid an unnecessary invocation of ‘grep’,
by using sed instead. Also, look only for at-most-3-digit numbers,
for consistency with the rest of the script.
-rw-r--r-- | gzexe.in | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -91,10 +91,11 @@ for i do continue fi if test $decomp -eq 0; then - if sed -e 1d -e 2q "$file" | grep "^skip=[0-9][0-9]*$" >/dev/null; then + case `sed -n -e 1d -e '/^skip=[0-9][0-9]*$/p' -e 2q "$file"` in + skip=[0-9] | skip=[0-9][0-9] | skip=[0-9][0-9][0-9]) printf >&2 '%s\n' "$0: $i is already gzexe'd" - continue - fi + continue;; + esac fi if test -u "$file"; then printf >&2 '%s\n' "$0: $i has setuid permission, unchanged" |