-
Notifications
You must be signed in to change notification settings - Fork 8.3k
command with wildcard characters on path cannot be executed #10997
Copy link
Copy link
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Steps to reproduce
Create an executable file with PowerShell wildcard characters in its name, say
a[hello].ps1, place it somewhere in the PATH, and then try to execute it from PowerShell.Expected behavior
The file executes
Actual behavior
It doesn't, but is suggested as a possible similar command.
There is no escaping of the wildcard characters that works.
Environment data
All version of PowerShell, on Windows 10, specifically 5.1, 6.2.3, and 7.0.0-preview5 were tested.
Reason - Determined from Debug
Because the command contains wildcard characters, it is rejected from a PATH search by
CommandSearcher.CanDoPathLookup()inCommandSearcher.setupPathSearcher(). If the command had been in the immediate path, using.\a[hello].ps1would have successfully worked.@mklement0, I believe you may have touched on this subject before, but I could not immediately find an existing issue for this.
I believe this can be corrected, by only sending an escaped version of the path to
CommandSearcher.CanDoPathLookup(), as I cannot find any reason that the path should not be treated literal at this point. Or, maybe the wildcard character check can be removed entirely, it appears this is the only place where the functionCanDoPathLookup()is used.