You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 #10675Fully 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:
Expected behavior
All tests should succeed.
Actual behavior
The 3rd test fails, because the partially quoted argument prevented
~expansion - even though~/is unquoted.Note that in POSIX-like shells - whose behavior here is being emulated -
/bin/echo ~/'foo bar'indeed expands~, as expected.Environment data