Package: unzip
Version: 6.0-25
Severity: normal
Tags: patch
Dear Maintainer,
If zipgrep is given one or more member names, none of which are present
in the archive, it produces errors such as the following:
caution: filename not matched: membername
/usr/bin/zipgrep: 97: test: -eq: unexpected operator
/usr/bin/zipgrep: 100: test: Illegal number:
Which can be reproduced by running:
zip motd.zip /etc/motd
zipgrep pattern motd.zip membername
This occurs because the sts variable is only set inside the loop over
member names present in the archive. This can be avoided by
initializing sts to 0 before the loop, as done by the attached patch.
Thanks for considering,
Kevin
-- System Information:
Debian Release: bullseye/sid
APT prefers testing-debug
APT policy: (990, 'testing-debug'), (990, 'testing'), (500,
'unstable-debug'), (500, 'unstable'), (101, 'experimental'), (1,
'experimental-debug')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.9.0 (SMP w/4 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages unzip depends on:
ii libbz2-1.0 1.0.8-4
ii libc6 2.31-3
unzip recommends no packages.
Versions of packages unzip suggests:
ii zip 3.0-11+b1
-- no debconf information
>From 0fc0fef8153e70f5cf956922512d8e2acbc626ea Mon Sep 17 00:00:00 2001
Message-Id:
<0fc0fef8153e70f5cf956922512d8e2acbc626ea.1602716158.git.ke...@kevinlocke.name>
From: Kevin Locke <[email protected]>
Date: Wed, 14 Oct 2020 16:46:23 -0600
Subject: [PATCH] zipgrep: Avoid test errors when no members present
If zipgrep is given one or more member names, none of which are present
in the archive, it produces errors such as the following:
caution: filename not matched: membername
/usr/bin/zipgrep: 97: test: -eq: unexpected operator
/usr/bin/zipgrep: 100: test: Illegal number:
Which can be reproduced by running:
zip motd.zip /etc/motd
zipgrep pattern motd.zip membername
This occurs because the sts variable is only set inside the loop over
member names present in the archive. Avoid it by initializing sts to 0.
Signed-off-by: Kevin Locke <[email protected]>
---
unix/zipgrep | 1 +
1 file changed, 1 insertion(+)
diff --git a/unix/zipgrep b/unix/zipgrep
index 69cd6ba..b9d2316 100755
--- a/unix/zipgrep
+++ b/unix/zipgrep
@@ -44,6 +44,7 @@ if test -n "$opt"; then
opt="-$opt"
fi
+sts=0
status_grep_global=1
IFS='
'
--
2.28.0