Home Dashboard Directory Help
Search

A here-string cannot contain blank line by Dardenne Laurent


Status: 

Active


7
0
Sign in
to vote
Type: Bug
ID: 571644
Opened: 6/29/2010 6:04:28 AM
Access Restriction: Public
1
Workaround(s)
view
4
User(s) can reproduce this bug

Description

In a here-string, the blank line are removed.

The end of line (LF) in a here-string, is not equal to System.Environment.NewLine(CR+LF).
Details
Sign in to post a comment.
Posted by jrich on 9/8/2010 at 7:17 AM
Oddly enough, This works as expected in ISE but not the console.
Posted by Michael_B_Smith on 8/25/2010 at 8:07 AM
This is true in interactive shell mode. When a line continuation character is displayed (">>"), if an empty line (or a line containing all spaces -- I presume it's actually a line containing all whitespace, but I didn't test) is entered, then the shell "swallows" the line. So...

$s = @'
aa

bb

cc
'@

is actually stored as

$s = @'
aa
bb
cc
'@

This error exists for both single and double quoted here-strings.

When executing a script file, this does not occur.
Sign in to post a workaround.
Posted by Christian.Bari on 1/24/2013 at 7:50 AM
If needed add a backticks in the empty line:

$string = @"
Line 1
`
Line 3
"@