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
{{ message }}
Repository navigation
Emulation of ~ (tilde) expansion for native utilities is incomplete #11386
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.
It's also missing support ~username syntax; for example, if I have a user foo with a home directory of /home/foo, even if I'm currently running as user bar, ~foo/test should expand to /home/foo/test. I don't think it's too important to prioritize that feature, since it's not widely known, but I figured I'd mention it.
Activity
Zenexer commentedon Dec 19, 2019
It's also missing support ~username syntax; for example, if I have a user
foowith a home directory of/home/foo, even if I'm currently running as userbar,~foo/testshould expand to/home/foo/test. I don't think it's too important to prioritize that feature, since it's not widely known, but I figured I'd mention it.rkitover commentedon Mar 14, 2020
No, I believe the ~user expansion is widely known, at least among linux developers and power users and is VERY useful.
E.g., I'm setting up an account for a friend on my windows server, I may want to do something like:
It should tab complete the expansion too.
SteveL-MSFT commentedon Apr 18, 2020
~username expansion should be a separate issue