src/relpipe-tr-sql.cpp
branchv_0
changeset 54 bc6e11cccdf4
parent 49 1d17192565bf
child 56 72305cea3b71
--- a/src/relpipe-tr-sql.cpp	Mon Oct 26 00:00:35 2020 +0100
+++ b/src/relpipe-tr-sql.cpp	Sun May 09 18:19:09 2021 +0200
@@ -59,7 +59,10 @@
 		if (configuration.listDataSources) {
 			// --list-data-sources:
 			SqlHandler::listDataSources(writer.get(), driverManager.get());
-		} else if (std::regex_match(cli.programName(), std::wregex(L"^(.*/)?relpipe-in-sql$"))) {
+			if (isatty(fileno(stdin)) && configuration.statements.empty() && configuration.copyRelations.empty()) goto end;
+		}
+
+		if (std::regex_match(cli.programName(), std::wregex(L"^(.*/)?relpipe-in-sql$"))) {
 			// relpipe-in-sql:
 			if (cli.arguments().size() == 0) configuration.copyRelations.push_back({L".*", L"", false});
 			configuration.sqlBeforeRelational = isatty(fileno(stdin)) ? nullptr : &std::wcin;
@@ -74,6 +77,7 @@
 			reader->process();
 		}
 
+end:
 		resultCode = CLI::EXIT_CODE_SUCCESS;
 
 	} catch (RelpipeCLIException& e) {