You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Powershell Core OSC9;9 string leaves residue in prompt after using grep from git-for-windows with pipe #13572
PS C:\Users\ACER> dir | grep 'pattern'# no match
PS C:\Users\ACER> ←]9;9;"C:\Users\ACER"
PS C:\Users\ACER>
PS C:\Users\ACER> dir | grep 'Documents'# matches
d-r--10/9/202111:04 PM Documents
PS C:\Users\ACER> ←]9;9;"C:\Users\ACER"
PS C:\Users\ACER>
PS C:\Users\ACER> grep -HnrIi 'damn' .\Documents\PowerShell\ # to show that without piping the bug doesn't appear
.\Documents\PowerShell\/Scripts/scratch.ps1:1:function Damn([string]$sym)
PS C:\Users\ACER>
PS C:\Users\ACER> dir |win32yank.exe-i # to show that the problem is not with piping
PS C:\Users\ACER>
Reproduction steps
Put the following in the $PROFILE.
functionprompt
{
$loc=Get-Location# Emulate standard PS prompt with location followed by ">"$out="PS $loc> "# Add current working directory (FileSystem)if ($loc.Provider.Name-eq"FileSystem") {
$out+="$([char]27)]9;9;`"$($loc.Path)`"$([char]7)"
}
return$out
}
Open a new PWSH tab in windows terminal.
Make sure git is in the $env:path and invoke:
dir | grep -i "pattern"
Versions of tools used
Windows Terminal: 1.15.2003.0 (why does wt -v not print in the console? I cannot even copy from the popup window.)
PowerShell Core: PowerShell 7.1.4
GIt for Windows: git version 2.33.0.windows.2
Discussions elsewhere
I mentioned in another issue -- may or may not be related -- that Windows Terminal crashes randomly if I use OSC9;9 string in the prompt. But I've been using the preview build for a week and it hasn't crashed yet. Update: I have had no crashes since then.
Activity
ghost added
Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
It is too sad to countenance. Funny enough, if you press Ctrl+C in any standard Windows message box, it DOES unexpectedly give you a hard copy of it:
---------------------------
Help
---------------------------
Windows Terminal Preview
1.16.2004.0
---------------------------
OK
---------------------------
I'm guessing this is related to msys restoring the console mode and turning off VT input . . . let me go digging, because I wrote this up before.
The symptoms here feel very similar to the ones dissected in #4921 (comment), which we traced back to an issue in the MSYS2 runtime that Git uses. I'm not sure whether the state of this issue has changed between 2.33 (the version you have installed) and 2.37 (the current version).
I can reproduce issue 4921. Although, I need to press enter once, then ←]9;9;"C:\Users\ACER" appears. Also, after git gui, if I run a command that produces an exception (apparently powershell errors and exceptions are different), the output is like this.
C:\Users\ACER> git gui
C:\Users\ACER> wrong_cmd hello world
←[91mwrong_cmd: ←[91mThe term 'wrong_cmd' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.←[0m
C:\Users\ACER> ←]9;9;"C:\Users\ACER"
So, basically terminal loses the ability to recognize the escape/special characters as escape/special characters, right?
I'm not sure whether the state of this issue has changed between 2.33 (the version you have installed) and 2.37 (the current version).
This issue persists with Msys2's grep command, too. And I regularly update msys.
Activity
DHowett commentedon Jul 22, 2022
It is too sad to countenance. Funny enough, if you press Ctrl+C in any standard Windows message box, it DOES unexpectedly give you a hard copy of it:
I'm guessing this is related to msys restoring the console mode and turning off VT input . . . let me go digging, because I wrote this up before.
3N4N commentedon Jul 22, 2022
This is way too fast a response. I feel guilty now. Take your time.
Live and learn.
DHowett commentedon Jul 22, 2022
Ha, don't! It's not a problem at all.
The symptoms here feel very similar to the ones dissected in #4921 (comment), which we traced back to an issue in the MSYS2 runtime that Git uses. I'm not sure whether the state of this issue has changed between 2.33 (the version you have installed) and 2.37 (the current version).
3N4N commentedon Jul 22, 2022
I can reproduce issue 4921. Although, I need to press enter once, then
←]9;9;"C:\Users\ACER"appears. Also, aftergit gui, if I run a command that produces an exception (apparently powershell errors and exceptions are different), the output is like this.So, basically terminal loses the ability to recognize the escape/special characters as escape/special characters, right?
This issue persists with Msys2's grep command, too. And I regularly update msys.
zadjii-msft commentedon Jul 25, 2022
Yea, this looks like the same thing. I'm game to call this a dupe (and reopen if I'm wrong).
/dup #4921