GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — properly escape trailing backslash so that it doesn't end up escaping the quotes by SteveL-MSFT · Pull Request #4965 · PowerShell/PowerShell Conversation
Member
When we create the arg string, an arg of The native command receives the arg as Fix #4358
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Steve Lee (SteveL-MSFT)
requested review from
Bruce Payette (BrucePay),
Dongbo Wang (daxian-dbw) and
sergei (vors)
as code owners
| |||||||||||||||||||||||||||||||||||||||||||
There was an error while loading. Please reload this page.
|
Since not every application use cmd /c 'echo \' will print Also you should not only double one cmd /c 'echo \\\' will print |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| It "Should correctly quote paths with spaces" { | ||
| $lines = testexe -echoargs '.\test 1\' '.\test 2\' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should we check double quotes?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Will add test
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
PetSerAl for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
How about multiple trailing testexe -echoargs '.\test 1\\' ".\test 2\\" |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
PetSerAl I'll work on that and add a test |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Apparently these strange trailing backslash and double quotes rules are documented |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -196,16 +196,28 @@ private void appendOneNativeArgument(ExecutionContext context, object obj, char | |||
| if (NeedQuotes(arg)) | |||
| { | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
How about:
_arguments.Append('"'); _arguments.Append(arg); for (int i = arg.Length-1; i >= 0 && arg[i] == '\\'; i--) { _arguments.Append('\\'); } _arguments.Append('"');
?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That's much better than my attempt. Will change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| for (int i = arg.Length-1; i >= 0 && arg[i] == '\\'; i--) | ||
| { | ||
| _arguments.Append(arg); | ||
| _arguments.Append('\\'); |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be "\\\\"?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No, unless you want to triplicate trailing \. arg already have one copy of \. This just adding second copy on top of it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarify!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dongbo Wang (@daxian-dbw) Jason Shirk (@lzybkr) Could you please review? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dongbo Wang (@daxian-dbw) Jason Shirk (@lzybkr) Could you please review? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dongbo Wang (@daxian-dbw) is in training today, Andrew (@anmenaga) can you review? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry that I missed the the first "@mention" notification. I will take a look later today. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… the quotes (PowerShell#4965) The native command receives the arg ".\test 1" as .\test 1" as the last \" is treated as escaping the quotes. Fix is to add an extra backslash to escape the last enclosing quote.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.