Skip to content

Conversation

@kzrnm
Copy link

@kzrnm kzrnm commented Oct 17, 2025

PR Summary

Fix #24178

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.

According to the comment added in #5188:

Supporting this scenario would require adding a NoteProperty to each quoted string argument - maybe not worth it, and maybe an argument for another way to suppress globbing.

https://github.com/kzrnm/PowerShell/blob/26bb188c8be0cda6cb548ce1a12840ebf67e1331/test/powershell/Language/Scripting/NativeExecution/NativeUnixGlobbing.Tests.ps1#L84-L88

However, I disagree with this comment. As noted in #24178, there are cases where one wants to use splatting without enabling globbing. Therefore, I believe implementing this via a NoteProperty would be worth it.

Additional considerations

When using an expression other than a string literal, such as /bin/echo "a*a".Replace("a",""), globbing is performed. This behavior is unintuitive, so I think it’s worth considering a breaking change to make it not perform globbing along with the above modification.

PR Context

PR Checklist

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unix: Native globbing cannot be bypassed when using splatting

1 participant