Command line parsing bug: spaces and trailing backslash
See original GitHub issueThis has already been posted on UserVoice (here), but appears to still happen in 6.0.
Steps to reproduce
Using any .exe capable of outputting its command line arguments:
PS X:\scratch> .\ps-args-test.exe .\test1\ '.\test 2\' .\test1\
Auto-completion uses this format with a trailing backslash, so it’s expected to work correctly.
Expected behavior
.\test1\
.\test 2\
.\test1\
Actual behavior
.\test1\
.\test 2" .\test1\
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.4
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Boost program_options trailing slash and space in path not ...
I have inherited a Visual Studio 2017 C++ command-line program on Windows that makes use of Boost's program_options:
Read more >SSH Can Handle Spaces In Command-line Arguments ...
First, your local shell expands arguments, which eats the backslash and combines two arguments into one. Then ssh passes all the arguments into ......
Read more >Why does my shell script choke on whitespace or other ...
I have an input line with two consecutive spaces and they shrank to one in the input. Leading and trailing whitespace disappears from...
Read more >%P parameter too strict - Total Commander
The %p is converted to 'F:\' (mind the trailing backslash) and mplayer really doesn't like that, it expects simply 'F:'. Also, when trying...
Read more >Deleting a directory with a trailing space in Windows 10/11
This is a workaround that tricks the command prompt into parsing the folder. Note the trailing backslash. My working theory is that by ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@daxian-dbw:
My sense is that once this RFC proposal by @TSlivede is implemented, it will cover this scenario too, so we probably don’t need a separate fix for this specific issue.
For background, see https://github.com/PowerShell/PowerShell/issues/1995#issuecomment-325231274
@mklement0 I see your point now. The problem is in
NativeCommandParameterBinder.cs
, which cause the argument passed in native commands like this: