I’m confused about the difference between these two things:
$env:path
And
function path {$env:path}
path
Both return strings, according to get-member. Yet -match does not work the same on both.
If I use -match on $env:path, it works as I’d expect, returning true/false. But if I use -match on path (the new function) then it always returns the path, ignoring the -match.
I’m confused because both return strings and therefore ought to work the same. Does the function need to do something special to get the same result?
David is right. The difference is that -match is being treated as a parameter to the path function. So,
or
works equally well. The former is a subexpression, the latter a nested pipeline (usually same effect in cases like this, but there are subtle differences.)
Verify:
-Oisin