Product, version and build: PSS 2016 5.2.117
32 or 64 bit version of product: x64
Operating system: Win7
32 or 64 bit OS: x64
Hi,
If I use "`" to wrap the line for better reading.
Sometimes it results in an Error. The Second Block is written as the first one.
If I remove all wordwraps the errors disappears, but the reading ... ;(.
That what I can reproduce is if the ` is without a space behind a String all is OK.
But if the `is without a space behind a variable the Error occours.
regards
mono
PSS 2016 5.2.117 - Problem with wordwraps
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: PSS 2016 5.2.117 - Problem with wordwraps
I've moved this post to the PowerShell forum so others can chime in as well.
While I can't find anything that directly states PowerShell requires a space before the escape character, the about_Escape_Characters file (https://technet.microsoft.com/en-us/lib ... 47755.aspx) has a space in the example for Line Continuation. If you were to take out that space, it won't work in a standard PowerShell console either.
While I can't find anything that directly states PowerShell requires a space before the escape character, the about_Escape_Characters file (https://technet.microsoft.com/en-us/lib ... 47755.aspx) has a space in the example for Line Continuation. If you were to take out that space, it won't work in a standard PowerShell console either.
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- juneblender
- Posts: 93
- Last visit: Thu Mar 30, 2017 8:54 am
Re: PSS 2016 5.2.117 - Problem with wordwraps
I suspect that you're right. I wrote about_Escape_Characters and, sadly, never thought to test the spaces before or after. We've learned that a space AFTER the backtick makes it ignored. I haven't seen any comments about a space before, but I've just tested it on a few cases (not conclusive).
I'm going to tweet this question to the PowerShell team (@PowerShell_Team) and Jason Shirk, the PS language dev, and get you a definitive answer. We should also do a User Voice request to update the help topic with this new information. Feel free to chime in.
https://twitter.com/juneb_get_help/stat ... 4743410688
Thanks so much for your post.
I'm going to tweet this question to the PowerShell team (@PowerShell_Team) and Jason Shirk, the PS language dev, and get you a definitive answer. We should also do a User Voice request to update the help topic with this new information. Feel free to chime in.
https://twitter.com/juneb_get_help/stat ... 4743410688
Thanks so much for your post.
- juneblender
- Posts: 93
- Last visit: Thu Mar 30, 2017 8:54 am
Re: PSS 2016 5.2.117 - Problem with wordwraps
Just got the definitive answer from Windows PowerShell MVP Kirk Munro (@poshoholic).
Preceding space required only if preceding token does not have enclosures. Otherwise the backtick becomes part of the preceding token rather than a continuation char. By enclosures I mean quotes, brackets, array/hashtable/multi-line comment enclosures, etc. By token I mean an unquoted value (string, numeric, etc.). e.g. gsv wuauserv` (in token).
I've filed a User Voice bug to update about_escape_characters: https://windowsserver.uservoice.com/for ... syntax-req
Preceding space required only if preceding token does not have enclosures. Otherwise the backtick becomes part of the preceding token rather than a continuation char. By enclosures I mean quotes, brackets, array/hashtable/multi-line comment enclosures, etc. By token I mean an unquoted value (string, numeric, etc.). e.g. gsv wuauserv` (in token).
I've filed a User Voice bug to update about_escape_characters: https://windowsserver.uservoice.com/for ... syntax-req
Re: PSS 2016 5.2.117 - Problem with wordwraps
Hi June,
I don't use Twitter but read the answers. Thanks for your post.
The solution is to use enclosures to prevent this problem? =)
regards
mono
(Tobias Philipp)
I don't use Twitter but read the answers. Thanks for your post.
The solution is to use enclosures to prevent this problem? =)
regards
mono
(Tobias Philipp)
Re: PSS 2016 5.2.117 - Problem with wordwraps
There is a much better method that is also very powerful. Splatting.
help about_splatting
help about_splatting
- #to splat a command
- $mysplatr = @{
- From = 'me@home.net'
- To = 'Me@work.org'
- Subject = 'The subject'
- SMTPServer = 'smtp.giggle.com'
- Port = 587
- BodyAsHtml=$true
- }
- $body = '>h1>Hello world</h1>'
- Send-MailMessage @mysplatr -Body $body
Re: PSS 2016 5.2.117 - Problem with wordwraps
A bit of an aside, but this highlights two things that might enhance PSS for some:
- A way to show hidden characters in the script (space and tab, specifically)
- An entry in the toolbar that would remove all trailing spaces/tabs from the file
Re: PSS 2016 5.2.117 - Problem with wordwraps
The PSS reformatter will do most of that and the syntax checker should catch most other issues. The backtic is an outlier which is why most of us recommend against its use and use splatting when necessary.
The line continuation is almost never needed. It was hotly debated when included in PowerShell but those who were used to BASIC wanted it so we are stuck with it. Just don't use it. It is very prone to breakage.
The line continuation is almost never needed. It was hotly debated when included in PowerShell but those who were used to BASIC wanted it so we are stuck with it. Just don't use it. It is very prone to breakage.