com_cpsi(): Tell the user if nothing was copied.
authorAndre Noll <maan@systemlinux.org>
Sun, 23 Feb 2014 09:57:04 +0000 (10:57 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 3 May 2014 17:53:10 +0000 (19:53 +0200)
All but the first argument to the cpsi command are treated as patterns.
Currently, if no file matches any given pattern, the command exits
silently.  This patch makes it print a "nothing copied" message in
this case.

aft.c

diff --git a/aft.c b/aft.c
index 179777ba8c8999dc633cf8578f08951ff7dd995c..39f95ad2517b15979a31545e79fae13c7ec33c7e 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -2409,13 +2409,12 @@ static void com_cpsi_callback(int fd, const struct osl_object *query)
 out:
        if (ret < 0)
                para_printf(&cad.pb, "%s\n", para_strerror(-ret));
 out:
        if (ret < 0)
                para_printf(&cad.pb, "%s\n", para_strerror(-ret));
-       else if (cad.flags & CPSI_FLAG_VERBOSE) {
-               if (pmd.num_matches > 0)
+       else if (pmd.num_matches > 0) {
+               if (cad.flags & CPSI_FLAG_VERBOSE)
                        para_printf(&cad.pb, "copied requested afsi from %s "
                                "to %u files\n", source_path, pmd.num_matches);
                        para_printf(&cad.pb, "copied requested afsi from %s "
                                "to %u files\n", source_path, pmd.num_matches);
-               else
-                       para_printf(&cad.pb, "nothing copied\n");
-       }
+       } else
+               para_printf(&cad.pb, "no matches - nothing copied\n");
        if (cad.pb.offset)
                pass_buffer_as_shm(fd, SBD_OUTPUT, cad.pb.buf, cad.pb.offset);
        free(cad.pb.buf);
        if (cad.pb.offset)
                pass_buffer_as_shm(fd, SBD_OUTPUT, cad.pb.buf, cad.pb.offset);
        free(cad.pb.buf);