question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Command line parsing bug: spaces and trailing backslash

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
mklement0commented, Sep 19, 2017

@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

2reactions
daxian-dbwcommented, Aug 4, 2017

@mklement0 I see your point now. The problem is in NativeCommandParameterBinder.cs, which cause the argument passed in native commands like this:

PS> testexe.exe -echoargs '.\test 2\'
Arg 0 is <.\test 2">
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found