microsoft / microsoft/terminal
Git bash intermittently won't clear screen when PS1 includes commands
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
### Windows Terminal version
1.19.2682.0
### Windows build number
10.0.22000.2416
### Other Software
Git for windows: 2.42.0.windows.2
### Steps to reproduce
1. Start a terminal running git bash (`%PROGRAMFILES%\\git\\bin\\sh.exe`)
2. Define a PS1 that echoes text to the screen:
```
PS1='$(echo -n "winterm echo> ")'
```
3. Run some commands that output text to the screen:
```
$ ls
$ pwd
```
4. Run `clear` to try and clear the screen contents:
```
$ clear
```
5. Sometimes the screen won't clear and the previous text will remain displayed on screen
6. When this happens, resizing the window or trying to select the text will clear the "ghost" text once, but the problem will continue to occur
### Expected Behavior
The screen should be cleared and return to a blank prompt
e.g.
```
winterm echo>
```
### Actual Behavior
Intermittently, the screen will not be cleared and the previous text will remain rendered to the screen.

-------------------------
The issue does not occur for "simple" PS1 that doesn't echo text to the screen:
i.e. this PS1 works:
```
PS1='winterm noecho> '
```
this PS1 will fail intermittently:
```
PS1='$(echo -n "winterm echo> ")'
```
-------------------------
Other information:
Issue first seen in Windows Terminal Preview Version: 1.19.2682.0
Works correctly in Windows Terminal Version: 1.17.11461.0
Same issue occurs in Windows 10 and Windows 11
Windows 10: 10.0.19045.3448
Windows 11: 10.0.22000.2416
I have only observed this issue with Git for Windows gitbash when updating to Windows Terminal Preview Version: 1.19.2682.0 (was working previously, with no change to bitbash
Have not observed the issue with any other terminal: WSL Ubuntu, Powershell, Command Prompt
Contributor guide
Assessment
This issue has not been assessed yet.