dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

CLI completion showing ^M after options #24268

Open drewnoakes opened 2 years ago

drewnoakes commented 2 years ago

Describe the bug

When using CLI completion in Git Bash, ^M characters are displayed after options.

image

To Reproduce

  1. Open Git Bash in Windows Terminal
  2. Type dotnet and press Tab a few times
  3. Notice ^M in output

Interestingly, this only appears after options, not after file names.

Further technical details

$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.200
 Commit:    4c30de7899

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.200\

Host (useful for support):
  Version: 6.0.2
  Commit:  839cdfb0ec
KalleOlaviNiemitalo commented 2 years ago

I was going to comment that I cannot reproduce this… but now I see my .bashrc defines _dotnet_bash_complete with | tr -d '\r', which is not part of https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#bash. I'm not sure whether I copied that definition from somewhere or added the tr myself.

drewnoakes commented 2 years ago

My .bashrc must've been using an older version of the code at that doc. I updated it and the ^M output is still present.

@KalleOlaviNiemitalo do you also see ^M?

KalleOlaviNiemitalo commented 2 years ago

I don't see ^M with my current .bashrc, but if I redefine _dotnet_bash_complete without the | tr -d '\r', then I see ^M.