summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntti-Juhani Kaijanaho <ajk@debian.org>2011-11-27 20:21:29 +0200
committerAntti-Juhani Kaijanaho <ajk@debian.org>2011-11-27 20:21:29 +0200
commitb0b6ee762f68f36999abc600e517f47af86cc608 (patch)
tree95964a893725488c51dc2149bed329252151f084
parent2510027ea14a15c7579b89e4c72491da1d69bef8 (diff)
downloaddctrl-tools-b0b6ee762f68f36999abc600e517f47af86cc608.tar.gz
Fix #641255: Output even a zero count (and exit successfully)
Signed-off-by: Antti-Juhani Kaijanaho <ajk@debian.org>
-rw-r--r--debian/changelog5
-rw-r--r--grep-dctrl/grep-dctrl.c4
-rw-r--r--tests/bug641255.in4
-rw-r--r--tests/bug641255.out1
-rw-r--r--tests/bug641255.sh8
5 files changed, 19 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index b26c4bf..92d427e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,8 +7,11 @@ dctrl-tools (2.20) UNRELEASED; urgency=low
is in dctrl format.
- Later on we may want to make --ensure-dctrl the default. In anticipation,
a --compat option has been added that countermands any --ensure-dctrl.
+ * grep-dctrl: With -c, output even a zero count and exit successfully.
+ Closes: #641255 (grep-dctrl -c does not print out 0 when it should)
+ [ Reported by Antti-Juhani Kaijanaho <ajk@debian.org> ]
- -- Antti-Juhani Kaijanaho <ajk@debian.org> Sun, 13 Nov 2011 20:24:48 +0200
+ -- Antti-Juhani Kaijanaho <ajk@debian.org> Sun, 27 Nov 2011 20:19:51 +0200
dctrl-tools (2.19) unstable; urgency=low
diff --git a/grep-dctrl/grep-dctrl.c b/grep-dctrl/grep-dctrl.c
index a7bf6f0..d43df2a 100644
--- a/grep-dctrl/grep-dctrl.c
+++ b/grep-dctrl/grep-dctrl.c
@@ -940,7 +940,7 @@ int main (int argc, char * argv[])
fsaf_close(fp);
close_ifile(fname, fd);
}
- if (count) printf("%zi\n", count);
- return errors_reported() ? 2 : found ? 0 : 1;
+ if (args.count) printf("%zi\n", count);
+ return errors_reported() ? 2 : found || args.count ? 0 : 1;
}
diff --git a/tests/bug641255.in b/tests/bug641255.in
new file mode 100644
index 0000000..100441f
--- /dev/null
+++ b/tests/bug641255.in
@@ -0,0 +1,4 @@
+Foo: bar
+
+Foo: baz
+
diff --git a/tests/bug641255.out b/tests/bug641255.out
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/bug641255.out
@@ -0,0 +1 @@
+0
diff --git a/tests/bug641255.sh b/tests/bug641255.sh
new file mode 100644
index 0000000..d526a9f
--- /dev/null
+++ b/tests/bug641255.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+LC_ALL=C
+export LC_ALL
+
+$GREP_DCTRL -c -FFoo xyzzy