Skip to content

Commit

Permalink
Fix double prompt issue in network_cli (ansible#35439)
Browse files Browse the repository at this point in the history
Fixes ansible#33993

In current implementation while trying to fetch the
current cli prompt terminal plugin executes `\r` on remote host.

This causes if command execution results in a prompt for
example executing `enable` command results in `Password:` prompt
there by executing `\r` on password prompt which is not intended.

To fix it while fetching current prompt from terminal plugin use `get_prompt()`
api in network_cli that returns the latest matched prompt instead of
unnecessary executing `\r` on remote host.
  • Loading branch information
ganeshrn authored Jan 31, 2018
1 parent dc35baa commit 3119188
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/ansible/plugins/terminal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ def _get_prompt(self):
:returns: A byte string of the prompt
"""
# do not send '\n' here, exec_cli_command sends '\r' already,
# doing so causes double prompts.
self._exec_cli_command(b'')

return self._connection._matched_prompt
return self._connection.get_prompt()

def on_open_shell(self):
"""Called after the SSH session is established
Expand Down

0 comments on commit 3119188

Please sign in to comment.