diff options
author | Alexander Sowitzki <asowitzk@redhat.com> | 2021-03-29 21:39:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 15:39:42 -0400 |
commit | 1527078a8f4fb80cb3f2c48c00b3e683086332eb (patch) | |
tree | 9d74101cf71b70cff29727b5824506ea0439a861 /lib/ansible/plugins/action | |
parent | a84c1a5669716f6c597a656c1fc02d42f60248ee (diff) | |
download | ansible-1527078a8f4fb80cb3f2c48c00b3e683086332eb.tar.gz |
pause - do not continue with '\r' when timeout is set (#74030)
Original function of pause was, to only allow user input
(finished with enter) when no timeout was set. This restores
the behaviour.
Diffstat (limited to 'lib/ansible/plugins/action')
-rw-r--r-- | lib/ansible/plugins/action/pause.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/ansible/plugins/action/pause.py b/lib/ansible/plugins/action/pause.py index cb36709168..728552ad7b 100644 --- a/lib/ansible/plugins/action/pause.py +++ b/lib/ansible/plugins/action/pause.py @@ -246,19 +246,20 @@ class ActionModule(ActionBase): clear_line(stdout) raise KeyboardInterrupt - # read key presses and act accordingly - if key_pressed in (b'\r', b'\n'): - clear_line(stdout) - break - elif key_pressed in backspace: - # delete a character if backspace is pressed - result['user_input'] = result['user_input'][:-1] - clear_line(stdout) - if echo: - stdout.write(result['user_input']) - stdout.flush() - else: - result['user_input'] += key_pressed + if not seconds: + # read key presses and act accordingly + if key_pressed in (b'\r', b'\n'): + clear_line(stdout) + break + elif key_pressed in backspace: + # delete a character if backspace is pressed + result['user_input'] = result['user_input'][:-1] + clear_line(stdout) + if echo: + stdout.write(result['user_input']) + stdout.flush() + else: + result['user_input'] += key_pressed except KeyboardInterrupt: signal.alarm(0) |