diff --git a/lib/ansible/plugins/action/pause.py b/lib/ansible/plugins/action/pause.py index 29ea79fc7e7..abe7ee6ae16 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)