Skip to content

about_parsing additional expression mode start characters #3440

@msftrncs

Description

@msftrncs

Issue Details

I have left the template blank at this time, but I believe this might affect all versions.


  • In argument mode, each value is treated as an expandable string unless it begins with one of the following special characters: dollar sign ($), at sign (@), single quotation mark ('), double quotation mark ("), or an opening parenthesis (().

If preceded by one of these characters, the value is treated as a value expression.


On about_parsing, there are additional characters that cause the expression mode, including:

  • '-' or '+' or '!' as long as it is in turn followed by a numeric value or one of the other mentioned characters, ie, a valid expression.

-$a or -2 or !$a is an expression mode
-hello or +hello or !test is an argument mode

Also, I think the last line should actually be part of the bulleted paragraph.

I think this whole section also fails to explain that the mode determination is based on the first token of each command statement and then applies to the remainder of the statement, noting that parenthesis and braces begin a new sub-statement. Instead this section implies that the mode is determine for each token (it mentions the tokens are interpreted independently, but they are not, as interpretation of all tokens after the first one depend on the first one's evaluation). Assuming a function named 'hello', hello $a-3, the token $a-3 is still treated as an expandable string, not an expression. An example in the doc also shows this, Write-Output $a/H.

Also, I think the word 'value' may have gotten used where 'token' should have been used, for consistency. The doc started off talking about 'tokens' and then switches to 'values' in the bulleted items.


Document Details

Do not edit this section. It is required for docs.microsoft.com GitHub issue linking.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions