Powershell: Start-Process fails in folder containing `[`

Created on 24 Feb 2020  路  5Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

mkdir "["
cd -LiteralPath "["
start cmd

Note

Start-Process works with the -WorkingDirectory option.

mkdir "["
cd -LiteralPath "["
start -WorkingDirectory . cmd

Expected behavior

Start-Process works

Actual behavior

start : The specified wildcard character pattern is not valid: [
At line:1 char:1
+ start cmd
+ ~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Start-Process], WildcardPatternException
+ FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.StartProcessCommand

Environment data

Tested with Powershell:
- 5.1 (Windows 10 1909)
- 6.2.4 (Windows 10 1909)
- 7.0.0 RC3 (Windows 10 1909)
Area-Cmdlets-Management Issue-Bug Resolution-Fixed

All 5 comments

I see the problem here and will put it in a pull request for it.

Really the issue asks to process WorkingDirectory as LiteralPath. I think we should do so. We consider WorkingDirectory as literal path for Start-Job and pwsh parameter.

/cc @mklement0 @SteveL-MSFT for conclusion.

@iSazonov As I mentioned in my PR for this, the redirection parameters also suffer from the parsing issue. The documentation says that these parameters do not support wildcards and it's hard to imagine what practical value processing them as patterns would have.

Related:

  • 4726 (> and >> treat the filename operand as a wildcard expression)

  • 6729 (Set-Content -Path not only treats its operand as a wildcard expression, but allows writing to _multiple_ files).

  • 9225 (variable namespace notation unexpectedly treats the item name as a wildcard expression)

:tada:This issue was addressed in #11946, which has now been successfully released as v7.1.0-preview.4.:tada:

Handy links:

Was this page helpful?
0 / 5 - 0 ratings