Open DanielSSilva opened 4 years ago
There might be a little confusion of what should be displayed here.
$ip:
is not a valid variable reference.
Here is your code on PR #156 when using a theme that highlights invalid constructs in bright red.
Note the squiggles from PSSA indicating the variable references are invalid.
Notice that the colon is green, since it "belongs" to the variable:
But notice that the prompt >
is red, indicating that something is wrong with the command.
The correct syntax is actually:
"pi@${ip}:/home/pi/PowerShell_IoT/"
Yap, I know that it is an invalid reference, but so is $ip:@
(I think).
Because I don't use PowerShell that much, I forgot that $variable:
is reserved for scope, but because it was not highlighted as an error, it took me a while to understand what was wrong.
So I think that what you showed with a theme that highlights is what's expected. Which theme is that btw?
The theme in my images is a modified Monokai Dimmed, https://github.com/msftrncs/theme-monokai-less-dimmed. Monokai Dimmed does provide an invalid scope.
What is more important is the work I put in to PR #156 so that the invalid variable reference was scoped as invalid. Currently, the variable constructs in the current repository requires a valid character after the ':' in order to be part of the scope or drive reference, and might not even consider any additional colons as valid at all, so you might have a point there. This appears to be what issue #49 was about. I've been running with PR #156 for so long I've forgotten this was an issue.
In $ip:@
, when contained within an expandable string, only the $ip:
would be considered invalid, as the @
would be considered just part of the string. @
is not allowed in a bare variable reference, but is only considered for a splatting operation if it is the first character in a bare-word argument.
Environment
Issue Description
From my tests, this seems to only happen if the colon is followed by some sort of special character such as - @ / etc
Screenshots
Expected Behavior
It should parse correctly, like this (taken from windows powershell). Notice that the colon is green, since it "belongs" to the variable:
Code Samples