Stéphane BARIZIEN ← Windows Server My feedback Windows PowerShell 5.1 hangs displaying result from Invoke-WebRequest 2 votes Vote Vote Vote Sign in prestine Your name Your email address (thinking…) Password Sign in with: Facebook Google Forgot password? Create a password I agree to the terms of service Signed in as (Sign out) Close Close Vote We’ll send you updates on this idea 0 comments · PowerShell » PowerShell Engine · Flag idea as inappropriate…Flag idea as inappropriate… · Delete… · Admin → Stéphane BARIZIEN shared this idea · Oct 19, 2020 Command line parsing bug: spaces and trailing slash 7 votes Vote Vote Vote Sign in prestine Your name Your email address (thinking…) Password Sign in with: Facebook Google Forgot password? Create a password I agree to the terms of service Signed in as (Sign out) Close Close Vote We’ll send you updates on this idea 4 comments · PowerShell » PowerShell Engine · Flag idea as inappropriate…Flag idea as inappropriate… · Delete… · Admin → An error occurred while saving the comment Stéphane BARIZIEN commented · Jun 15, 2019 · Edit… · Delete… I confirm this issue, detected in the first place with a script that invokes ROBOCOPY.EXE (which is part of Windows). Here's my repro script, and its output (args.exe is my homegrown equivalent to EchoArgs, that I wrote a zillion years ago): ----------------------------8<--------------------------------------------- $xmldata = @' <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"> <S>/s</S> <S>/xx</S> <S>/xo</S> <S>/np</S> <S>\\bar\c$\a b\</S> <S>E:\foo</S> </Objs> '@ $xmlfile = Join-Path -Path $env:TEMP -ChildPath 'VSCodeArgsProblem_data.xml' $xmldata | Out-File $xmlfile $robocopy_args = Import-Clixml -LiteralPath $xmlfile Remove-Item -LiteralPath $xmlfile & args $robocopy_args ----------------------------8<--------------------------------------------- ----------------------------------------- Universal command line arguments debugger argv[0] = 's:\bin\windows\x86\Args.exe' ----------------------------------------- argv[0]='s:\bin\windows\x86\Args.exe' strlen(argv[0]) = 27 argv[1]='/s' strlen(argv[1]) = 2 argv[2]='/xx' strlen(argv[2]) = 3 argv[3]='/xo' strlen(argv[3]) = 3 argv[4]='/np' strlen(argv[4]) = 3 argv[5]='\\bar\c$\a b" E:\foo' strlen(argv[5]) = 20 sum(strlen(argv[i])) = 58 Current working directory: 'C:\Users\steph' GetCommandLine() = '"s:\bin\windows\x86\Args.exe" /s /xx /xo /np "\\bar\c$\a b\" E:\foo' strlen(GetCommandLine()) = 67 ----------------------------8<--------------------------------------------- Save Submitting...
I confirm this issue, detected in the first place with a script that invokes ROBOCOPY.EXE (which is part of Windows).
Here's my repro script, and its output (args.exe is my homegrown equivalent to EchoArgs, that I wrote a zillion years ago):
----------------------------8<---------------------------------------------
$xmldata = @'
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<S>/s</S>
<S>/xx</S>
<S>/xo</S>
<S>/np</S>
<S>\\bar\c$\a b\</S>
<S>E:\foo</S>
</Objs>
'@
$xmlfile = Join-Path -Path $env:TEMP -ChildPath 'VSCodeArgsProblem_data.xml'
$xmldata | Out-File $xmlfile
$robocopy_args = Import-Clixml -LiteralPath $xmlfile
Remove-Item -LiteralPath $xmlfile
& args $robocopy_args
----------------------------8<---------------------------------------------
-----------------------------------------
Universal command line arguments debugger
argv[0] = 's:\bin\windows\x86\Args.exe'
-----------------------------------------
argv[0]='s:\bin\windows\x86\Args.exe'
strlen(argv[0]) = 27
argv[1]='/s'
strlen(argv[1]) = 2
argv[2]='/xx'
strlen(argv[2]) = 3
argv[3]='/xo'
strlen(argv[3]) = 3
argv[4]='/np'
strlen(argv[4]) = 3
argv[5]='\\bar\c$\a b" E:\foo'
strlen(argv[5]) = 20
sum(strlen(argv[i])) = 58
Current working directory: 'C:\Users\steph'
GetCommandLine() = '"s:\bin\windows\x86\Args.exe" /s /xx /xo /np "\\bar\c$\a b\" E:\foo'
strlen(GetCommandLine()) = 67
----------------------------8<---------------------------------------------