You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect arg splitting when using .. syntax for git log #15279
In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
It's definitely surprising and unhelpful behavior that has been in place since v3 (in v2 you get a "Missing property name after reference operator." error).
Just to provide some background:
An argument that looks like a property access is usually treated as such:
PS> cmd /c echo $PSHOME.Length# with .HEAD, $null would result, and no argument would be passed.35# e.g.
Seemingly, if what follows the first . isn't a syntactically valid property name, the argument is simply broken in two at the first . (and the variable reference is expanded and stringified as a whole), whereas it would make much more sense to implicitly treat the argument as an expandable string (as if it were enclosed in "..."), which is what otherwise happens, e.g., with cmd /c echo /$PSHOME..HEAD (because the token doesn't start with $).
The rules around how unquoted compound tokens are parsed and sometimes broken up in argument mode are surprisingly complex, and there are other surprises - see #6467 and MicrosoftDocs/PowerShell-Docs#3440 (comment)
You've already stated the workaround - double-quoting - which is always a way to avoid ambiguity, but it would certainly be nice if that weren't necessary.
The change in behavior from v2 to v3 indicates that fallback behavior was deliberately introduced - it's just that the fallback chosen is unhelpful.
With the new 7.2-preview.5 native command parameter binding tracing, the problem is that git is being sent the value of $tag and ..HEAD as two parameters instead of one:
PS> $tag = git describe --tags --abbrev=0PS> trace-command -Option ExecutionFlow -Name ParameterBinding -Expression { git log $tag..HEAD --oneline } -PSHostDEBUG: 2021-04-20 06:52:38.3359 ParameterBinding Information: 0 : BIND NAMED native application line args [/usr/bin/git]DEBUG: 2021-04-20 06:52:38.3468 ParameterBinding Information: 0 : BIND cmd line arg [log] to position [0]DEBUG: 2021-04-20 06:52:38.3475 ParameterBinding Information: 0 : BIND cmd line arg [v7.2.0-preview.5] to position [1]DEBUG: 2021-04-20 06:52:38.3475 ParameterBinding Information: 0 : BIND cmd line arg [..HEAD] to position [2]DEBUG: 2021-04-20 06:52:38.3475 ParameterBinding Information: 0 : BIND cmd line arg [--oneline] to position [3]DEBUG: 2021-04-20 06:52:38.4365 ParameterBinding Information: 0 : CALLING BeginProcessing
Replacing the variable with a literal shows what is expected:
PS> trace-command -Option ExecutionFlow -Name ParameterBinding -Expression { git log v7.2.0-preview.5..HEAD --oneline } -PSHostDEBUG: 2021-04-20 06:53:39.0736 ParameterBinding Information: 0 : BIND NAMED native application line args [/usr/bin/git]DEBUG: 2021-04-20 06:53:39.0754 ParameterBinding Information: 0 : BIND cmd line arg [log] to position [0]DEBUG: 2021-04-20 06:53:39.0755 ParameterBinding Information: 0 : BIND cmd line arg [v7.2.0-preview.5..HEAD] to position [1]DEBUG: 2021-04-20 06:53:39.0762 ParameterBinding Information: 0 : BIND cmd line arg [--oneline] to position [2]DEBUG: 2021-04-20 06:53:39.1816 ParameterBinding Information: 0 : CALLING BeginProcessing
Mathias R. Jessen (@IISResetMe) mentioned on twitter that it seems to occur at the tokenizer. In argument mode the tokenizer doesn't correctly revert back to a single expandable string when it hits the second period and instead creates a variable token and a literal string token.
Reacted by Michael Klement and Rain Sallow (/u/ta11ow)
Thanks for the clarification, Patrick Meinecke (@SeeminglyScience); indeed, the problem also happens in regular parameter binding, not just when calling native executables.
Given that a native executable happened to be the messenger, if you will, in this case, perhaps Steve Lee (@SteveL-MSFT) merely meant to showcase the new-in-preview.5 ability to also trace parameter binding when calling native executables, which is indeed good to know (though incidental here).
Given that a native executable happened to be the messenger, if you will, in this case, perhaps Steve Lee (@SteveL-MSFT) merely meant to showcase the new-in-preview.5 ability to also trace parameter binding when calling native executables, which is indeed good to know (though incidental here).
Ahh good point! Didn't know that was new, I definitely misread that.
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.
In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
Activity
iSazonov commentedon Apr 20, 2021
Does this work before 7.2.0-preview.3? In 7.1?
mklement0 commentedon Apr 20, 2021
It's definitely surprising and unhelpful behavior that has been in place since v3 (in v2 you get a "Missing property name after reference operator." error).
Just to provide some background:
An argument that looks like a property access is usually treated as such:
Seemingly, if what follows the first
.isn't a syntactically valid property name, the argument is simply broken in two at the first.(and the variable reference is expanded and stringified as a whole), whereas it would make much more sense to implicitly treat the argument as an expandable string (as if it were enclosed in"..."), which is what otherwise happens, e.g., withcmd /c echo /$PSHOME..HEAD(because the token doesn't start with$).The rules around how unquoted compound tokens are parsed and sometimes broken up in argument mode are surprisingly complex, and there are other surprises - see #6467 and MicrosoftDocs/PowerShell-Docs#3440 (comment)
You've already stated the workaround - double-quoting - which is always a way to avoid ambiguity, but it would certainly be nice if that weren't necessary.
The change in behavior from v2 to v3 indicates that fallback behavior was deliberately introduced - it's just that the fallback chosen is unhelpful.
SteveL-MSFT commentedon Apr 20, 2021
With the new 7.2-preview.5 native command parameter binding tracing, the problem is that
gitis being sent the value of$tagand..HEADas two parameters instead of one:Replacing the variable with a literal shows what is expected:
SeeminglyScience commentedon Apr 20, 2021
Steve Lee (@SteveL-MSFT) The issue has existed since version 3 (as noted by Michael Klement (@mklement0) above) and happens with any command (e.g.
$i = '10'; echo $i..HEAD).Mathias R. Jessen (@IISResetMe) mentioned on twitter that it seems to occur at the tokenizer. In argument mode the tokenizer doesn't correctly revert back to a single expandable string when it hits the second period and instead creates a variable token and a literal string token.
mklement0 commentedon Apr 20, 2021
Thanks for the clarification, Patrick Meinecke (@SeeminglyScience); indeed, the problem also happens in regular parameter binding, not just when calling native executables.
Given that a native executable happened to be the messenger, if you will, in this case, perhaps Steve Lee (@SteveL-MSFT) merely meant to showcase the new-in-preview.5 ability to also trace parameter binding when calling native executables, which is indeed good to know (though incidental here).
SeeminglyScience commentedon Apr 20, 2021
Ahh good point! Didn't know that was new, I definitely misread that.
microsoft-github-policy-service commentedon Oct 13, 2024
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.