Skip to content

Fix trailing carriage return in aws_completer on Windows - #10730

Open
UditDewan wants to merge 1 commit into
aws:v2from
UditDewan:fix-completer-crlf
Open

UditDewan wants to merge 1 commit into
aws:v2from
UditDewan:fix-completer-crlf

Conversation

@UditDewan

Copy link
Copy Markdown

Issue #, if available: Fixes #9135

Description of changes:

On Windows, sys.stdout translates \n to \r\n. When aws_completer is used from Git Bash (MINGW64), bash keeps the trailing \r as part of each completion, so every suggestion shows up with a ^M after it.

autocomplete() now reconfigures stdout to write \n line endings before printing completions. On Linux/macOS this is a no-op.

Verified on Windows 11 by piping COMP_LINE="aws ec" aws_completer through od -c:

  • before: e c 2 \r \n e c 2 - i n s t a n c e - c o n n e c t \r \n ...
  • after: e c 2 \n e c 2 - i n s t a n c e - c o n n e c t \n ...

Added a unit test that simulates a CRLF-translating stdout. It fails without the change and passes with it. tests/unit/autocomplete and tests/functional/autocomplete/test_main.py pass (233 tests).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

On Windows, sys.stdout translates "\n" to "\r\n". Shells such as Git
Bash (MINGW64) keep the trailing "\r" as part of each completion,
which shows up as "^M" after every suggestion.

Write completions with "\n" line endings regardless of platform.

Fixes aws#9135

Co-authored-by: Baradhan Madhavan <222307534+Baradhan-Madhu@users.noreply.github.com>
@UditDewan
UditDewan requested a review from a team as a code owner October 5, 2026 23:20

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws_completer outputs "^M" after every suggestion in MINGW(64) on Windows Terminal

1 participant