Native globbing: Automatic globbing for native commands doesn't work with backtick-escaped spaces
See original GitHub issueSee also (the inverse problem): https://github.com/PowerShell/PowerShell/issues/18038
When calling external programs (native programs) on Unix-like platforms, wildcard patterns that you want automatic globbing applied to (as in Bash, for instance) must be unquoted, i.e. they must neither be enclosed in single quotes nor in double quotes.
Therefore, if you want globbing to be applied to a wildcard pattern that has spaces, for instance, you need to individually escape the space, namely as `
However, the automatic globbing mechanism currently doesn’t recognize that and doesn’t expand such patterns.
Steps to reproduce
On Linux (native globbing is currently fundamentally broken on macOS, and isn’t applied on Windows)
Push-Location temp:/
touch 'a b.txt'
/bin/echo a` * | Should -Be 'a b.txt'
Remove-Item 'a b.txt'
Pop-Location
Expected behavior
The test should succeed.
Actual behavior
The test fails, because the pattern is not expanded ('a *'
is echoed).
Environment data
PowerShell Core v7.0.0-preview.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Workaround is to wrap any globbing with
(Get-ChildItem ...)
. This is also a problem on Windows using utilities ported from Unix which expect globbing to be expanded by shell. Examples:@iSazonov: Not in terms of native globbing, as far as I can tell, but you can do the following: