diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-06-30 10:53:24 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-06-30 12:56:21 +0200 |
commit | 3e3a2e5394a619807f9f4930263ccf4d3fee269a (patch) | |
tree | 7ffe3622d9aa8711f30a1bdcac4f6e8e49f0b0bc | |
parent | 3b1b083182aa8662815478db092be4358e467a7e (diff) | |
download | dialog-rs-3e3a2e5394a619807f9f4930263ccf4d3fee269a.tar.gz dialog-rs-3e3a2e5394a619807f9f4930263ccf4d3fee269a.tar.bz2 |
Fix input and password dialogs for zenity backend
Previously, we tried to read the user input from zenity’s stderr
although it is written to stdout. This patch changes the zenity backend
to read from stdout instead of stderr. It also removes trailing
newlines from the user input, as zenity adds a newline when writing the
input.
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | src/backends/zenity.rs | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f0be7c..ba8e822 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Unreleased +- Fix the input and password dialogs for the `zenity` backend (thanks Silvano + Cortesi for the bug report): + - Read from `stdout` instead of `stderr`. + - Remove trailing newlines from the result. + # v0.2.0 (2019-01-11) - Refactor `default_backend` to return a `Box<dyn Backend>`. - Check the `DIALOG` and `DISPLAY` environment variables in `default_backend`. diff --git a/src/backends/zenity.rs b/src/backends/zenity.rs index 0730c64..85206b3 100644 --- a/src/backends/zenity.rs +++ b/src/backends/zenity.rs @@ -128,8 +128,8 @@ fn get_choice(status: process::ExitStatus) -> Result<Choice> { fn get_stdout(output: process::Output) -> Result<Option<String>> { if output.status.success() { - String::from_utf8(output.stderr) - .map(|s| Some(s)) + String::from_utf8(output.stdout) + .map(|s| Some(s.trim_end_matches('\n').to_string())) .map_err(|err| Error::from(err)) } else { if let Some(code) = output.status.code() { |