Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

single quote in here-string causes TerminatorExpectedAtEndOfString in V5.0 #2780

Copy link
Copy link
@m8ram

Description

@m8ram
Issue body actions

Steps to reproduce

$herestr=@"
'"'
"@
Write-Host $herestr

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:

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)

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.