Skip to content

Need syntax or cmdlet for globbing with space (i.e. glue quoted literals with globs) #13098

Closed

Description

I found this issue while trying to take on #13089 myself. It's a minor headache to be unable to glob stuff with escapes and embedded spaces. This is not a limitation in POSIX shell, nor is it one in the original glob(3) language.

Steps to reproduce

# prepare
$a = mktemp -d
cd $a
mkdir "A B"
# test
/bin/echo "A "*
/bin/echo *' B'
/bin/echo *` B
# ast poke sans globbing
Write-Output "A "*
Write-Output *' B'

Expected behavior

A B
A B
A B
(pwsh stuff)
(pwsh stuff)

Actual behavior

A  A B
* B
* B
A 
*
* B

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Darwin 19.5.0 Darwin Kernel Version 19.5.0: Tue…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

How did this happen?

Test case (4) indicates that the parser sees two string literals glued together as two distinct "words". This could be improved without breakings stuff by just making a cmdlet for globbing a mixture of quoted (to be escaped) and bare (to be put into the pattern raw) character runs.

Test case (3) indicates that the heuristic in NativeCommandParameterBinder::AppendOneNativeArgument is inadequate. Even when fed a valid glob, it sees the space in the string and decides that it is non-globbable from that. Bad idea.

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jul 4, 2020
  2. added
    WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
    Issue-Enhancementthe issue is more of a feature request than a bug
    and removed
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jan 17, 2021
  3. Artoria2e5 commented on Nov 20, 2023

    @Artoria2e5
    Author

    Four in a row!

  4. microsoft-github-policy-service commented on May 18, 2024

    @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

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimeWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions