Package: zstd
Version: 1.3.8+dfsg-2
Severity: normal

Dear Maintainer(s),

the search command zstdgrep always returns an exit code of 1 when
called with file name(s).
The logic with EXIT_CODE and CUR_EXIT_CODE in that shell script seems
bogus to me. Shouldn't something simple like

EXIT_CODE=0
...
    [ "$?" -ne 0 ] && EXIT_CODE=1
...

work?
I attach a patch which also corrects a minor nit regarding the *egrep and *fgrep
variants.

Regards,
Jörg.
--- zstdgrep.orig	2019-01-03 14:47:31.000000000 +0100
+++ zstdgrep	2019-01-05 19:16:01.697399037 +0100
@@ -35,8 +35,8 @@
 
 # handle being called 'zegrep' or 'zfgrep'
 case "${prg}" in
-    *zegrep) grep_args="-E";;
-    *zfgrep) grep_args="-F";;
+    *zstdegrep) grep_args="-E";;
+    *zstdfgrep) grep_args="-F";;
 esac
 
 # skip all options and pass them on to grep taking care of options
@@ -113,16 +113,11 @@
     if [ "${silent}" -lt 1 ] && [ "$#" -gt 1 ]; then
         grep_args="-H ${grep_args}"
     fi
-    CUR_EXIT_CODE=0
-    EXIT_CODE=1
     set -f
     while [ "$#" -gt 0 ]; do
         # shellcheck disable=SC2086
         "${zcat}" -fq -- "$1" | "${grep}" --label="${1}" ${grep_args} -- "${pattern}" -
-        CUR_EXIT_CODE=$?
-        if [ "${CUR_EXIT_CODE}" -eq 0 ] && [ "${EXIT_CODE}" -ne 1 ]; then
-            EXIT_CODE=0
-        fi
+        [ "$?" -ne 0 ] && EXIT_CODE=1
         shift
     done
     set +f

Reply via email to