From d3f406dfe113f0a7f7b1dcd3fada4c2b7e7cd23c Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Fri, 16 May 2014 11:02:33 -0700
Subject: [PATCH] Let qtpaths return a failure to the caller if it found
 nothing

Otherwise, the only hint that we get that nothing was found is an empty
line. You could detect that from a shell by assigning to a variable and
checking if it's empty (provided $IFS is set to a newline). But a return
value is much easier.

Change-Id: I00608be8a23a487c9f90a4080479c8f527a8eb3f
Reviewed-by: David Faure <david.faure@kdab.com>
---
 src/qtpaths/qtpaths.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/qtpaths/qtpaths.cpp b/src/qtpaths/qtpaths.cpp
index 74534e86a..91941558b 100644
--- a/src/qtpaths/qtpaths.cpp
+++ b/src/qtpaths/qtpaths.cpp
@@ -64,7 +64,7 @@ static void message(const QString &string)
 Q_NORETURN static void error(const QString &message)
 {
     fprintf(stderr, "%s\n", qPrintable(message));
-    ::exit(1);
+    ::exit(EXIT_FAILURE);
 }
 
 
@@ -285,10 +285,13 @@ int main(int argc, char **argv)
     if (results.isEmpty()) {
         parser.showHelp();
     } else if (results.size() == 1) {
-        message(results.first());
+        const QString &item = results.first();
+        message(item);
+        if (item.isEmpty())
+            return EXIT_FAILURE;
     } else {
         QString errorMessage = QCoreApplication::translate("qtpaths", "Several options given, only one is supported at a time.");
         error(errorMessage);
     }
-    return 0;
+    return EXIT_SUCCESS;
 }
-- 
GitLab