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
A string containing a single-quote, a double quote and another single quote should be printed to stdout.
According to Powershell "about quoting rules":
A here-string is a single-quoted or double-quoted string in which quotation marks are interpreted literally.
Actual behavior
A TerminatorExpectedAtEndOfString is thrown in version 5.0 (with version 2.0 the actual behaviour is as expected).
If I escape the last single quote with a backtick the behaviour is also as expected in V5.0
Environment data
Powershell version 5.0 (build 10586, revision 117) throws the exception.
In a Powershell version 2.0 it works as expected
You can workaround this by putting extra space: $herestr =@"... or $herestr= @"...; or by enclosing in parenthesis: ($herestr=@"..."@)
The option of enclosing in parenthesis causes the here document to be echoed but I can confirm that these options work in V5.0 (build 10586, revision 117)
Steps to reproduce
Expected behavior
A string containing a single-quote, a double quote and another single quote should be printed to stdout.
According to Powershell "about quoting rules":
A here-string is a single-quoted or double-quoted string in which quotation marks are interpreted literally.
Actual behavior
A TerminatorExpectedAtEndOfString is thrown in version 5.0 (with version 2.0 the actual behaviour is as expected).
If I escape the last single quote with a backtick the behaviour is also as expected in V5.0
Environment data
Powershell version 5.0 (build 10586, revision 117) throws the exception.
In a Powershell version 2.0 it works as expected
Additional information
According to feedback I received on superuser.com escaping the single quote is not the only way to work around this. Other options are: