-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior in PS7 with replacing specific bytes in While-clause #14956
Comments
The short of it:
The problem boils down to this:
For instance: # Escape sequence "`a" is [char] 7
'Food' -eq "Foo`ad" # !! $true in .NET 5+ - the non-printing control character is *ignored* // C# equivalent
"Food".Equals("Foo\ad", StringComparison.InvariantCultureIgnoreCase) |
That's an interesting change to be made. Do you happen to know if that was documented anywhere? Seems like it should have been considered a breaking change and doc'd somewhere as a result. |
I agree, @vexx32 - a cursory web search didn't provide any clues. Searching the issues at https://github.com/dotnet/runtime/issues I did find this, which may explain the change (I haven't dug deeper): dotnet/runtime#43736 (comment)
|
WG-Engine: We reviewed this issue and agreed to document the behavior changes to @sdwheeler Would it be OK to document this in https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-72?view=powershell-7.2#breaking-changes-and-improvements?
|
The document update PR is out: MicrosoftDocs/PowerShell-Docs#8672 |
For no other reason than to challenge myself, I tried to make one of my scripts to use as less bytes as possible.
I need to find all double closing brackets and separate them:
To describe this here I use a TAB to have a visible character. In my code I pasted a
[char]7
(that will never be in the input text).This works in 5.1, 6.2 and 7.1
To make my code shorter I used this:
This also works in 5, 6 and 7 if you use a TAB (pasted, not `t).
With
[char]7
it's OK in Powershell 5 and 6, but fails in 7.Actual behavior in PS7
The results of bytes 9 to 13 are as expected. In PS5 or PS6 all bytes result in the correct output.
Why does this behave different for specific values?
Environment data
The text was updated successfully, but these errors were encountered: