Re:Why Does Windows Use Backslash as Path Separator?
by itslennysfault on Wednesday April 24, 2024 @06:06PM
(#40150359)
As a long time *nix user who briefly worked at Microsoft (and therefore on Windows), I was very happy to learn that Powershell is perfectly happy with forward slashes in paths. If you tab-complete it switches them to backslashes (which is "fine"), but you can type commands using forward slashes without issue. Also common linux commands (ls, cd, mv, cp) all work in Powershell. It really makes the transition painless.
[ Parent
| on HN ]
Re:Why Does Windows Use Backslash as Path Separator?
by wglb on Wednesday April 24, 2024 @07:06PM
(#40150985)
This is also true if you e.g. write a C program to create a file whose pathname contains a slash. This is deep within the OS, likely due to posix compatibility
Re:Why Does Windows Use Backslash as Path Separator?
by Alupis on Wednesday April 24, 2024 @06:08PM
(#40150408)
I personally have found PowerShell to be obnoxious. It doesn't seem to know what it's supposed to be and tries to be everything all at once. The syntax for commands is super "Microsofty" if you know what I mean.
I get around by using Git Bash (which is actually quite good for being a bundled afterthought), cygwin, or lately even WSL containers.
Re:Why Does Windows Use Backslash as Path Separator?
by sbelskie on Wednesday April 24, 2024 @06:13PM
(#40150473)
What different things do you think it is trying to be?
Re:Why Does Windows Use Backslash as Path Separator?
by therein on Wednesday April 24, 2024 @06:26PM
(#40150601)
I have nothing against PowerShell. I've used it for avoiding detection etc. in the past. Fun tool that surprises and delights in unexpected ways.
It is pretty powerful/insane that stuff like this is a part of PowerShell and that's probably what the GP is talking about:
Add-Type -TypeDefinition @"
using System;
namespace DemoCode
{
public class DemoClass
{
public static void WriteHello()
{
Console.WriteLine("Hello");
}
}
}
"@
[DemoCode.DemoClass]::WriteHello()
Or LoadLibrary call and invocation from PowerShell. [0] [1]It blurs the lines as to what it is no matter how you look at it.
In contrast, try doing that in cmd.exe or invoking a function from a shared object after getting a pointer to it using dlopen through a POSIX shell.
[0] - https://www.powershellgallery.com/packages/PSReflect-Functio...
Re:Why Does Windows Use Backslash as Path Separator?
by TiredOfLife on Thursday April 25, 2024 @05:25AM
(#40155269)
Git Bash, cygwin, WSL containers are all completely different things. PowerShell is a shell like bash, just with a different syntax.
Re:Why Does Windows Use Backslash as Path Separator?
by naikrovek on Wednesday April 24, 2024 @06:51PM
(#40150837)
Windows itself is fine with forward slashes as a path separator, as well, though LOTS of userland Windows applications weren’t aware of this and enforced backslashes themselves.
Command lines, graphical shells, OS save and open file dialogs do not care if you use slash or backslash, and the Win32 API has never enforced backslashes as a path separator.
Re:Why Does Windows Use Backslash as Path Separator?
by Dwedit on Wednesday April 24, 2024 @07:32PM
(#40151255)
You'll be surprised what the Win32 API will accept as a path. You can run 'type \\?\GLOBALROOT\Device\OSDataDevice\Windows\win.ini' at a command prompt, and it will succeed. You can even provide a path like that to MS Paint on the command line, and it will happily open the file. But Shell32 (Windows Explorer and File Load/Save dialogs) won't accept that kind of path.
Re:Why Does Windows Use Backslash as Path Separator?
by Nihilartikel on Wednesday April 24, 2024 @06:20PM
(#40150544)
I work a lot in powershell, and I want to like it. It is built around good ideas.. but oof, every time I have to special case on a return value being either a list or a single item depending on the result-len==1 or not, I die a little inside.
Re:Why Does Windows Use Backslash as Path Separator?
by ScottEvtuch on Wednesday April 24, 2024 @06:39PM
(#40150719)
I think there are some tricks to ensure a list in pwsh for these sort of operations. I vaguely recall ending variable assignments with a comma to avoid this.
Re:Why Does Windows Use Backslash as Path Separator?
by jiggawatts on Wednesday April 24, 2024 @06:47PM
(#40150806)
$alwaysList = @( Get-Something )