summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-05-16 11:02:33 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-18 02:08:16 +0200
commitd3f406dfe113f0a7f7b1dcd3fada4c2b7e7cd23c (patch)
tree82d7a4cc691674ad0d10fd8b77adb86137f06ec0
parent24e4c294bd4405cc4ce73a013af833ef67bb2a26 (diff)
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>
-rw-r--r--src/qtpaths/qtpaths.cpp9
1 files 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;
}