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
Resolve file paths before passing to native commands #10675
On Windows, the ~ is only understood by PowerShell. So if you try: notepad ~\foo.txt, it complains it can't find the file path. On Windows and non-Windows PSDrives have no meaning outside of PowerShell, so you can't do something like pico temp:/temp.txt with expectation that you're creating a file in the temp drive.
The problem is determining if the file path should be resolved or if it's a literal string being passed to the native command. In most cases, it would seem that resolving the path would be fine. Literal strings can have quotes around them making it explicit.
Resolving PSDrive-based paths to native filesystem paths on all platforms sounds like a nice enhancement.
Yes, on Unix quoting is already being used to distinguish between a (potential) filesystem path to be ~-resolved and globbed (unquoted) and a literal argument (quoted), a nod to POSIX-like shells.
However, the automatic globbing is probably not a good idea on Windows, where it is up to the target command to expand globs (wildcard expressions).
So that gives us the following - is that what you had in mind?
All platforms:
Expand unquoted (token-initial) ~ (as before, only if followed by an unquoted path separator or nothing at all)
Activity
mklement0 commentedon Oct 2, 2019
Resolving PSDrive-based paths to native filesystem paths on all platforms sounds like a nice enhancement.
Yes, on Unix quoting is already being used to distinguish between a (potential) filesystem path to be
~-resolved and globbed (unquoted) and a literal argument (quoted), a nod to POSIX-like shells.However, the automatic globbing is probably not a good idea on Windows, where it is up to the target command to expand globs (wildcard expressions).
So that gives us the following - is that what you had in mind?
All platforms:
Expand unquoted (token-initial)
~(as before, only if followed by an unquoted path separator or nothing at all)Convert an unquoted path that starts with a PS-only drive spec to a native filesystem path (if it's a filesystem PS drive).
Unix-like platforms only: