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

Ensure systemRoot() always has trailing separator character #616

Merged
merged 9 commits into from
Dec 18, 2024

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Dec 16, 2024

PR Summary

Change so that systemRoot() always includes a trailing separator. This is due to how PathBuf.push() works on Windows vs non-Windows and path() adopts this behavior:

  • On Windows, if you join a drive letter c: and windows, you get c:windows which is a relative path to the current c: drive location
  • On Windows, if you join a drive letter in the middle, it's treated as absolute and replaces the previous path segments: 'a', 'c:', 'b' will be c:b, you would use c:\ to make sure it's absolute
  • On non-Windows, the colon is valid directory character, so nothing special happens and is allowed

Added extra tests to path() that aren't needed for this PR, but good to have.

dsc_lib/src/functions/path.rs Outdated Show resolved Hide resolved
@SteveL-MSFT SteveL-MSFT changed the title Fix path() function where first arg is a drive letter to add separator Ensure systemRoot() always has trailing separator character Dec 17, 2024
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Dec 18, 2024
Merged via the queue into PowerShell:main with commit e875e2e Dec 18, 2024
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the path-windows branch December 18, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants