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
Tokenizer treats . as a separator when parsing a parameter token, which causes problem to argument parsing for native commands #15541
I use powershell to run build commands like mvn --% install -Dmaven.test.skip -Dmaven.repo.local=.m2/repository -Dbuild.deployAtEnd=true -Dgib.disable
I NEVER expect the dot to act like a property selection operator. I don't want to have to quote every time I use a dot, and I'd rather not have to specify --% for every command.
Is it reasonable to expect a setting in pwsh.runtimeconfig.json to disable parsing of command arguments? Call it dumb mode or whatever.
You're not the first person to suggest that, but the fact is I've never seen it work without --%, on many machines running powershell 5 or 7. There's even a difference in the syntax highlighting
BTW there is some work going on WRT argument parsing in 7.2 - see PR #15408. However whether the mode is set to Standard or Legacy, PS still parses that mvn command line differently than cmd.exe does.
That feels like a bug, tbh. I don't see any good reason for the . characters to have special meaning. There aren't any variables or other special tokens involved here.
changed the title [-]Feature Request: dumb mode, i.e. a no parse arguments setting[/-][+]Tokenizer treats `.` as a separator when parsing a parameter token, which causes problem to argument parsing for native commands[/+]on Jun 9, 2021
I ran into this again on macOS with the updated native command passing:
g++ ./hello.cpp -target arm64-apple-macos11 -mmacosx-version-min=11.0 -o hello_arm
clang: error: no such file or directory: '.0'
You can quote the 11.0 to get around this or use --%. The issue seems to be that -mmacosx-version-min=11 is considered a parameter name by PowerShell, followed by a .0 as a ConstantExpressionAst. Possible fix is to recognize this situation in the NativeCommandProcessor and fix up the resulting parameter passed to the native app.
Keith Hill (@rkeithhill), it's the same old bug, #6291, and it is both unrelated to and long predates $PSNativeCommandArgumentPassing, as are the other linked bugs.
The simplest workaround is to quote the whole argument: '-mmacosx-version-min=11.0'
If the token contains no spaces or other PowerShell metacharacters, `-escaping the initial - is enough: `-mmacosx-version-min=11.0
Another one of those, "why? why" issues with PowerShell.
It's great that PowerShell has extra features and some simplifications. But why should it complicate standard commands? Like why should we change the way we invoke Java since 1997 just because we start using PowerShell? (I can't guarantee that Java has supported -D since 1997, but it's been around quite a while.)
Activity
vexx32 commentedon Jun 8, 2021
Unless I'm missing something, you shouldn't need to use
--%most of the time. That command you have there will work as-is without it, I'd think.delanym commentedon Jun 8, 2021
You're not the first person to suggest that, but the fact is I've never seen it work without --%, on many machines running powershell 5 or 7. There's even a difference in the syntax highlighting
What makes you think I don't need the --% ?
rkeithhill commentedon Jun 8, 2021
Yeah, there is a difference without
--%:Using
--%in PS:BTW there is some work going on WRT argument parsing in 7.2 - see PR #15408. However whether the mode is set to
StandardorLegacy, PS still parses thatmvncommand line differently than cmd.exe does.vexx32 commentedon Jun 8, 2021
That feels like a bug, tbh. I don't see any good reason for the
.characters to have special meaning. There aren't any variables or other special tokens involved here.[-]Feature Request: dumb mode, i.e. a no parse arguments setting[/-][+]Tokenizer treats `.` as a separator when parsing a parameter token, which causes problem to argument parsing for native commands[/+]daxian-dbw commentedon Jun 9, 2021
It looks
.is used as a separator when tokenizing text like a parameter (e.g. -xxx)Another native command argument parsing issue related to tokenizer: #15279
ceztko commentedon May 6, 2022
This seems the same as the older #6291. I fail to understand if this a confirmed bug and if this will be solved in a future version of powershell.
mklement0 commentedon Sep 8, 2022
Good point, Francesco Pretto (@ceztko). In fact,
is just one of several related bugs, which the following search surfaces ("Parameter parsing.passing" in the title, 8 issues as of this writing):
rkeithhill commentedon Nov 28, 2022
I ran into this again on macOS with the updated native command passing:
You can quote the
11.0to get around this or use--%. The issue seems to be that-mmacosx-version-min=11is considered a parameter name by PowerShell, followed by a.0as aConstantExpressionAst. Possible fix is to recognize this situation in the NativeCommandProcessor and fix up the resulting parameter passed to the native app.mklement0 commentedon Nov 28, 2022
Keith Hill (@rkeithhill), it's the same old bug, #6291, and it is both unrelated to and long predates
$PSNativeCommandArgumentPassing, as are the other linked bugs.The simplest workaround is to quote the whole argument:
'-mmacosx-version-min=11.0'If the token contains no spaces or other PowerShell metacharacters,
`-escaping the initial-is enough:`-mmacosx-version-min=11.0garretwilson commentedon Mar 16, 2023
Another one of those, "why? why" issues with PowerShell.
It's great that PowerShell has extra features and some simplifications. But why should it complicate standard commands? Like why should we change the way we invoke Java since 1997 just because we start using PowerShell? (I can't guarantee that Java has supported
-Dsince 1997, but it's been around quite a while.)delanym commentedon Sep 7, 2023
Also, I can't use
--%in commands which invoke a script. For example with this script "fast.ps1"And this command
fast --% somethingThe token "--%" gets passed to Maven. So I'm forced to quote.
doggy8088 commentedon Mar 6, 2024
Delany (@delanym) What's your
$PSNativeCommandArgumentPassingvalue?delanym commentedon Mar 6, 2024
Will 保哥 (@doggy8088) i just installed Powershell 7.4.1 and the value is "Windows"
delanym commentedon Mar 6, 2024
https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-features?view=powershell-7.4#psnativecommandargumentpassing
It makes no difference whether this property is set to Windows, Standard or Legacy.
ceztko commentedon Sep 10, 2024
Maybe this issue should be kept open/assigned a milestone?