Set-Location \ behaviour inconsistent between operating systems
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
In #18308 we found that running cd\
will do different things depending on the operating system.
Steps:
- Navigate to any directory above your drive’s root level. >
Set-Location Drive:/LizardPhotos/Skinks
- Run
Set-Location \
orcd\
- You should now be at your drive’s root on windows, or your filesystem root on Linux & Mac.
Expected behavior
Windows, Mac, and Linux set location as the root of the current drive on`cd\`
Actual behavior
Windows sets location to the root of the current drive.
Mac and Linux sets location to the filesystem root.
Error details
N/A
Environment data
Name Value
---- -----
PSVersion 7.3.0-preview.9
PSEdition Core
GitCommitId 7.3.0-preview.9
OS Microsoft Wind…
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0…
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Vertical ViewPager and Android Pie Inconsistent Behavior ...
My Vertical ViewPager works wonderfully and consistently within any device I have tested and with any OS 5 - 8. I recently upgraded...
Read more >Inconsistent Data · Stellarium stellarium · Discussion #214
Inconsistent data, which occurs two different ways. repeat event on PC several days apart. Clarification: mark event (e.g. Acronycal Setting of Arcturus on...
Read more >JFrame (Java SE 11 & JDK 11 )
The JFrame class is slightly incompatible with Frame . Like all other JFC/Swing top-level containers, a JFrame contains a JRootPane as its only...
Read more >JFrame (Java Platform SE 7 )
getDefaultCloseOperation. Returns the operation that occurs when the user initiates a "close" on this frame.
Read more >Differences between Windows PowerShell 5.1 and ...
The most notable differences are in the availability and behavior of PowerShell cmdlets between Windows and non-Windows platforms and the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Since some of us already redefine CD to be something other than an alias for set location, that could be incorporated into a CD function.
/ is defined as a PS Drive on linux to ensure that cd / does in PowerShell what it does in other unix/linux shells What happens in all shells on the same OS is consistent rather than making pwsh on linux “windows like” and annoying linux oriented folks.
While consistency across platforms is generally desirable, I fear that’s not an option here:
On Unix, if you make
/
refer to the root of a drive (which on Unix is by definition only ever a PS drive), you won’t be able to change to the actual file-system root whenever the current location is drive-based.Pragmatically speaking:
Set-Location Temp:/
isn’t too much of a hardship.Set-Location ($PWD.Path -replace '(?<=[\\/]).*')