[augeas-devel] augeas: master - * src/augtool.c: ignore empty lines from stdin
David Lutterkort
lutter at fedoraproject.org
Mon Feb 22 20:02:56 UTC 2010
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=6c7f09a92a33c668f8c36f99d9d54fe98006e4e0
Commit: 6c7f09a92a33c668f8c36f99d9d54fe98006e4e0
Parent: c80d1be4c40628f0738bcf37578bc10e32976fce
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Mon Feb 22 12:01:15 2010 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Mon Feb 22 12:01:15 2010 -0800
* src/augtool.c: ignore empty lines from stdin
We still complain about the nonsensical 'augtool ""'.
Fixes BZ 566844 reported by Mike Burns
---
src/augtool.c | 2 +-
tests/Makefile.am | 3 ++-
tests/test-augtool-empty-line.sh | 21 +++++++++++++++++++++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/augtool.c b/src/augtool.c
index ab412fd..a0c09e2 100644
--- a/src/augtool.c
+++ b/src/augtool.c
@@ -1092,7 +1092,7 @@ static int main_loop(void) {
printf("\n");
return ret;
}
- if (line[0] == '#')
+ if (*line == '\0' || *line == '#')
continue;
code = run_command(line);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cb40a48..e577623 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -107,7 +107,8 @@ check_SCRIPTS = \
test-get.sh \
test-put-symlink.sh test-save-empty.sh test-mv.sh \
test-bug-1.sh test-idempotent.sh test-preserve.sh \
- test-events-saved.sh test-save-mode.sh test-unlink-error.sh
+ test-events-saved.sh test-save-mode.sh test-unlink-error.sh \
+ test-augtool-empty-line.sh
EXTRA_DIST = \
augtest $(AUGTESTS) root lens-test-1 \
diff --git a/tests/test-augtool-empty-line.sh b/tests/test-augtool-empty-line.sh
new file mode 100755
index 0000000..8b4bb42
--- /dev/null
+++ b/tests/test-augtool-empty-line.sh
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+# Test for BZ 566844. Make sure we don't spew nonsense when the input
+# contains empty lines
+out=$(augtool --nostdinc 2>&1 <<EOF
+
+quit
+EOF
+)
+result=$?
+
+if [ $result -ne 0 ]; then
+ echo "augtool failed"
+ exit 1
+fi
+
+if [ -n "$out" ]; then
+ echo "augtool produced output:"
+ echo "$out"
+ exit 1
+fi
More information about the augeas-devel
mailing list