[augeas-devel] [PATCH] Fix cmd_span (ticket #220)

Raphaël Pinson raphink at gmail.com
Thu Oct 6 13:10:29 UTC 2011


 - Retrieve option from tree before using it;
 - Invert conditions since we now use streqv.
---
 src/augrun.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/augrun.c b/src/augrun.c
index 636b6fe..901c150 100644
--- a/src/augrun.c
+++ b/src/augrun.c
@@ -621,13 +621,17 @@ static void cmd_span(struct command *cmd) {
     char *filename = NULL;
     const char *option = NULL;

-    if (! streqv(AUG_DISABLE, option)) {
+    if (aug_get(cmd->aug, AUGEAS_SPAN_OPTION, &option) != 1) {
+        printf("Error: option " AUGEAS_SPAN_OPTION " not found\n");
+        return;
+    }
+    if (streqv(AUG_DISABLE, option)) {
         ERR_REPORT(cmd, AUG_ECMDRUN,
                    "Span is not enabled. To enable, run the commands:\n"
                    "    set %s %s\n    rm %s\n    load\n",
                    AUGEAS_SPAN_OPTION, AUG_ENABLE, AUGEAS_FILES_TREE);
         return;
-    } else if (streqv(AUG_ENABLE, option)) {
+    } else if (! streqv(AUG_ENABLE, option)) {
         ERR_REPORT(cmd, AUG_ECMDRUN,
                    "option %s must be %s or %s\n", AUGEAS_SPAN_OPTION,
                    AUG_ENABLE, AUG_DISABLE);
-- 
1.7.0.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20111006/66bab55a/attachment.htm>


More information about the augeas-devel mailing list