Skip to content

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

Closed

Description

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 

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Oct 2, 2019
  2. iSazonov commented on Oct 7, 2019

    @iSazonov
    Collaborator

    Is there a workaround?

  3. mklement0 commented on Oct 7, 2019

    @mklement0
    ContributorAuthor

    Ilya (@iSazonov): Not in terms of native globbing, as far as I can tell, but you can do the following:

     /bin/echo (Get-Item 'a *').Name
  4. iSazonov commented on Oct 7, 2019

    @iSazonov
    Collaborator

    It seems a dup #10675.

  5. mklement0 commented on Oct 7, 2019

    @mklement0
    ContributorAuthor

    It's not a duplicate, because the linked issue relates to resolving PS-drive-based paths to native paths, (which would also apply to Windows), whereas this issue is related to the (Unix-only) native-globbing feature.

  6. iSazonov commented on Oct 8, 2019

    @iSazonov
    Collaborator

    Really the resolving is executed by the same LocalGlobbig code. So technically it is one issue.

  7. mklement0 commented on Oct 8, 2019

    @mklement0
    ContributorAuthor

    I see: it happens to be technically related rather than a duplicate.

  8. changed the title [-]Automatic globbing for native commands doesn't work with backtick-escaped spaces[/-] [+]Native globbing: Automatic globbing for native commands doesn't work with backtick-escaped spaces[/+] on Sep 6, 2022
  9. dkaszews commented on Sep 6, 2022

    @dkaszews
    Contributor

    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:

    vim *.txt # bash: opens all txt files bash, pwsh: opens file '*.txt'
    vim (Get-ChildItem *.txt)  # bash and pwsh: opens all txt files
  10. dkaszews commented on Nov 28, 2023

    @dkaszews
    Contributor
  11. 6 remaining items

  12. dkaszews commented on Nov 25, 2024

    @dkaszews
    Contributor

    Repro on 7.4.6

  13. dkaszews commented on May 25, 2025

    @dkaszews
    Contributor

    Repro on 7.5.1

  14. microsoft-github-policy-service commented on Nov 22, 2025

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

    Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.

  15. xtqqczze commented on Dec 2, 2025

    @xtqqczze
    Contributor
  16. microsoft-github-policy-service commented on Jun 1, 2026

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

    Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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 aResolution-No ActivityIssue has had no activity for 6 months or moreWG-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