diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-01-28 18:00:20 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-02-04 14:27:15 +0200 |
commit | a7b0eead83379d9343429a37efa8e39f924e8525 (patch) | |
tree | 1ede0a98dec8dbd9c3503872990e36c850a4380c /src/libs/installer/packagemanagercore.cpp | |
parent | 8dcc1bb8ceabcd30dd3c73c2f9fa23393f6602a8 (diff) |
CLI: Exit when expecting user input and the output device is not a TTY
- For arbitrary text input queries, fail and exit.
- For file/directory queries, fail and exit.
- For message boxes, default to negative option and exit if necessary.
Task-number: QTIFW-1949
Change-Id: Iaf8a07247a0e358d4544a856788e48447c6720d9
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer/packagemanagercore.cpp')
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 4a0d2c191..ed513fb69 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -971,6 +971,8 @@ QString PackageManagerCore::readFile(const QString &filePath, const QString &cod * characters. If \a maxlen is 0, the line can be of any length. * * \note Can be only called when installing from command line instance without GUI. + * If the output device is not a TTY, i.e. when forwarding to a file, the function + * will throw an error. * * \sa {installer::readConsoleLine}{installer.readConsoleLine} */ @@ -978,6 +980,10 @@ QString PackageManagerCore::readConsoleLine(const QString &title, qint64 maxlen) { if (!isCommandLineInstance()) return QString(); + if (LoggingHandler::instance().outputRedirected()) { + throw Error(tr("User input is required but the output " + "device is not associated with a terminal.")); + } if (!title.isEmpty()) qDebug() << title; QTextStream stream(stdin); |