[folks] inspect: Ensure terminal state is restored if PAGER cannot be spawned
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] inspect: Ensure terminal state is restored if PAGER cannot be spawned
- Date: Wed, 25 Feb 2015 15:01:51 +0000 (UTC)
commit f0021c4a8c68ccda1242655c81d2d5b669dbb136
Author: Philip Withnall <philip withnall collabora co uk>
Date: Wed Feb 25 14:59:43 2015 +0000
inspect: Ensure terminal state is restored if PAGER cannot be spawned
If $PAGER cannot be spawned (e.g. due to not existing, or due to the
user not having permission to run it), we would previously leave the
terminal with the readline handler uninstalled. Correctly restore the
readline state instead, and redisplay the current prompt.
This avoids leaving the user with no way to enter text or kill
folks-inspect in cases similar to
PAGER=really-doesnt-exist folks-inspect
tools/inspect/inspect.vala | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/tools/inspect/inspect.vala b/tools/inspect/inspect.vala
index 4209020..5f4af1b 100644
--- a/tools/inspect/inspect.vala
+++ b/tools/inspect/inspect.vala
@@ -369,9 +369,21 @@ public class Folks.Inspect.Client : Object
command.run.begin (subcommand, (obj, res) =>
{
command.run.end (res);
- /* Close the stream to the pager so it knows it's reached EOF. */
- main_client._pager_channel = null;
- Utils.output_filestream = GLib.stdout;
+
+ if (main_client._pager_channel != null)
+ {
+ /* Close the stream to the pager so it knows it's
+ * reached EOF. */
+ main_client._pager_channel = null;
+ Utils.output_filestream = GLib.stdout;
+ }
+ else
+ {
+ /* Failed to start the pager in the first place. */
+ Readline.reset_line_state ();
+ Readline.replace_line ("", 0);
+ Readline.redisplay ();
+ }
});
}
@@ -443,6 +455,10 @@ public class Folks.Inspect.Client : Object
catch (SpawnError e2)
{
warning ("Error spawning pager: %s", e2.message);
+
+ /* Reinstall the readline handler and stdin handler. */
+ this._install_readline_and_stdin ();
+
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]