summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Pentchev <roam@debian.org>2018-11-27 11:09:15 +0200
committerPeter Pentchev <roam@debian.org>2018-11-27 11:09:15 +0200
commitbe257830adef2918f8d6b3401d462df124d642cd (patch)
tree1063bb7163f3f672e7ef3fe561c1835501ead527
parent5393b0ca60f912b4d8935550b15f305ce3a21783 (diff)
parente632e229358105dd3010006f3fda2c0712230cf9 (diff)
Merge confget-2.1.1 into the Debian branch.
-rw-r--r--CHANGES3
-rw-r--r--confget.c7
-rw-r--r--t/14-too-many.t62
3 files changed, 69 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index 9f5176f..ad4ce17 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
Change log for confget, the configuration file variable extractor
+2.1.1 2018/11/27
+ - fix the check for more than one requested query type
+
2.1.0 2017/11/11
- allow the installation commands to be overridden, e.g. for
package builds which do not require root privileges
diff --git a/confget.c b/confget.c
index 366c3b1..054c765 100644
--- a/confget.c
+++ b/confget.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2008, 2009, 2012, 2013, 2016, 2017 Peter Pentchev
+ * Copyright (c) 2008, 2009, 2012, 2013, 2016 - 2018 Peter Pentchev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -185,7 +185,7 @@ usage(const bool error)
void
version(void)
{
- puts("confget 2.1.0");
+ puts("confget 2.1.1");
}
/***
@@ -337,7 +337,8 @@ init(const int argc, char * const * const argv)
{ "BASE", "2.1" },
{ NULL, NULL },
};
- if (qsections + qfeature + qfeatures > 1) {
+ if (qsections + qfeature + qfeatures + lflag + Lflag +
+ (margc > 0 && !(Lflag || qfeature)) > 1) {
errx(1, "Only a single query at a time, please!");
} else if (qfeatures) {
if (margc > 0)
diff --git a/t/14-too-many.t b/t/14-too-many.t
new file mode 100644
index 0000000..5949fe3
--- /dev/null
+++ b/t/14-too-many.t
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# Copyright (c) 2018 Peter Pentchev
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
+[ -z "$CONFGET" ] && CONFGET='./confget'
+[ -z "$TESTDIR" ] && TESTDIR='t'
+
+T1="$TESTDIR/t1.ini"
+T2="$TESTDIR/t2.ini"
+
+echo '1..13'
+
+if [ ! -f "$T1" ]; then
+ echo "Bail out! No test file $T1"
+ exit 255
+fi
+if [ ! -f "$T2" ]; then
+ echo "Bail out! No test file $T2"
+ exit 255
+fi
+
+idx=1
+for args in \
+ '-l -L k' \
+ '-l -q sections' \
+ '-l -q features' \
+ '-l -q feature BASE' \
+ '-l key1' \
+ '-L -q sections k' \
+ '-L -q features k' \
+ '-L -q feature BASE k' \
+ '-q sections -q features' \
+ '-q sections -q feature BASE' \
+ '-q sections key1' \
+ '-q features -q feature BASE' \
+ '-q features key1'; do
+ v=`$CONFGET -f "$T2" $args 2>&1`
+ if expr "x$v" : 'x.*Only a single ' > /dev/null; then echo "ok $idx $args"; else echo "not ok $idx args $args v is $v"; fi
+ idx="$((idx + 1))"
+done