-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Milestone
Description
Note:
-
~expansion for native utilities currently fundamentally only works on Unix platforms - but Windows would benefit from it too: see Resolve file paths before passing to native commands #10675 -
Fully emulating the logic of
~expansion in PowerShell requires recognizing partial quoting of sub-tokens in arguments (e.g.,~/'foo bar'), which may turn out to be a challenge based on how argument parsing currently works.
Steps to reproduce
On a Unix-like platform:
# Quoting the argument as a whole always suppresses ~ expansion.
/bin/echo '~/foo' | Should -Be '~/foo'
# Both commands should expand ~ to the value of $HOME,
# because the ~/ prefix is unquoted.
/bin/echo ~/foo | Should -Not -BeLike '~/*'
/bin/echo ~/'foo bar' | Should -Not -BeLike '~/*'Expected behavior
All tests should succeed.
Actual behavior
The 3rd test fails, because the partially quoted argument prevented ~ expansion - even though ~/ is unquoted.
Expected like wildcard '~*' to not match '~/foo bar', but it did match.
Note that in POSIX-like shells - whose behavior here is being emulated - /bin/echo ~/'foo bar' indeed expands ~, as expected.
Environment data
PowerShell Core 7.0.0-rc.1
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.