summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Doran <sdoran@ansible.com>2017-10-26 12:05:08 -0400
committeransibot <ansibot@users.noreply.github.com>2017-10-26 12:05:08 -0400
commit104934c09565ddeb4c4d14bb9c283c5639988466 (patch)
tree86dcf08d3ccb1194a657dc7cb7059ea66e408303
parentc8222923477d339c5f9ac3b66d986717e41dd4dc (diff)
downloadansible-104934c09565ddeb4c4d14bb9c283c5639988466.tar.gz
Enable ECHO in prompt module (#32083)
* Enable ECHO in prompt module Fixes #14160 * Set flags to make it possible to edit echoed input as well as hide control charcters Only do this if a time limit is not set. * Consolidate settings
-rw-r--r--lib/ansible/plugins/action/pause.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/ansible/plugins/action/pause.py b/lib/ansible/plugins/action/pause.py
index 29ea79fc7e..abe7ee6ae1 100644
--- a/lib/ansible/plugins/action/pause.py
+++ b/lib/ansible/plugins/action/pause.py
@@ -140,6 +140,20 @@ class ActionModule(ActionBase):
old_settings = termios.tcgetattr(fd)
tty.setraw(fd)
+ # Enable a few things turned off by tty.setraw()
+ # ICANON -> Allows characters to be deleted and hides things like ^M.
+ # ICRNL -> Makes the return key work when ICANON is enabled, otherwise
+ # you get stuck at the prompt with no way to get out of it.
+ # ECHO -> Echos input back to stdout
+ #
+ # See man termios for details on these flags
+ if not seconds:
+ new_settings = termios.tcgetattr(fd)
+ new_settings[0] = new_settings[0] | termios.ICRNL
+ new_settings[3] = new_settings[3] | (termios.ICANON | termios.ECHO)
+ termios.tcsetattr(fd, termios.TCSANOW, new_settings)
+ termios.tcsetattr(fd, termios.TCSANOW, new_settings)
+
# flush the buffer to make sure no previous key presses
# are read in below
termios.tcflush(stdin, termios.TCIFLUSH)