Skip to content

Resolve file paths before passing to native commands #10675

Closed

Description

@SteveL-MSFT

Summary of the new feature/enhancement

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.

Proposed technical implementation details (optional)

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.

Activity

  1. added this to the Future milestone on Oct 1, 2019
  2. mklement0 commented on Oct 2, 2019

    @mklement0
    Contributor

    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:

      • Perform globbing (expansion to individual filename arguments based on wildcard patterns) on unquoted paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions