Skip to content

Unix: Native globbing cannot be bypassed when using splatting #24178

Open
@mklement0

Description

Prerequisites

Steps to reproduce

Note: This has been reported before, but not as a dedicated issue:

On Unix, barewords passed as arguments to external (native) programs are subject to globbing (filename expansion), if they contain * or ?, for compatibility with native Unix shells.

  • In direct invocation, the way to avoid this is to quote the bareword, e.g. '*'

  • However - and this constitutes the bug - when splatting, the globbing cannot be prevented:

# On Unix-like platforms.
/bin/echo @( '*' )

Note that using embedded quoting (e.g., @('"*"')) is not an option, because it becomes part of the argument.

Expected behavior

* should print verbatim.

Note:

  • The above assumes that '*' should not be treated like a bareword in the context of splatting, which in turn implies that you fundamentally cannot specify barewords that way, and would have to use something like @((Get-Item * -Name)) to manually perform the desired globbing.

  • This strikes me as an acceptable trade-off and much preferable to the alternative: defaulting to interpretation as barewords, with a yet-to-be-devised opt-out method.

Actual behavior

The names of the files and subdirectories in the current directory print, because native globbing was applied.

Error details

No response

Environment data

PowerShell 7.5.0-preview.3 on Unix-like platforms.

Visuals

No response

Metadata

Assignees

No one assigned

    Labels

    WG-Interactive-Consolethe console experienceWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions