Skip to content

Native globbing: Automatic globbing for native commands doesn't work with backtick-escaped spaces #10683

@mklement0

Description

@mklement0

See also (the inverse problem): #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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions