Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ~\ for Windows paths in Path#expand and File.expand_path #11559

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Dec 9, 2021

Path#expand and File.expand_path are currently hardcoded to traverse from the home directory only for paths starting with ~/, but ~\ should be valid for Windows paths, and Powershell for example does support ~\. This PR adds it.

The construction File.expand_path(File.join("~", "a"), home: true) now produces a subdirectory of the home directory, and works on both POSIX and Windows paths.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system labels Dec 9, 2021
src/path.cr Outdated Show resolved Hide resolved
HertzDevil and others added 2 commits December 9, 2021 20:33
Co-authored-by: Johannes Müller <[email protected]>
@straight-shoota straight-shoota added this to the 1.3.0 milestone Dec 9, 2021
@straight-shoota straight-shoota merged commit ca32044 into crystal-lang:master Dec 13, 2021
@HertzDevil HertzDevil deleted the feature/path-windows-home-backslash branch December 14, 2021 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants