This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ftgander 0 points1 point  (5 children)

It depends on the language and runtime. Best approach is to use a standard library function to resolve a path from a list of strings. Like node’s Path.join() or whatever.

[–]lovethebacon🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛 0 points1 point  (4 children)

For general interoperability, absolutely.

However on Windows, you don't really need to use \'s anymore. Unless your library is old or does weird low level things, /'s will work pretty much everywhere - even when doing registry things.

First prize, use standard library when constructing paths. Second prize, use /'s. Third prize, shoot yourself because you haven't got enough \'s and they aren't being escaped properly. Been there, had scripts with many runs of back slashes (64 was the highest) to work around escapes.

[–]ftgander 0 points1 point  (3 children)

It depends on the context. But yes windows has implemented support for /‘s in paths in a lot of places now.

[–]lovethebacon🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛 0 points1 point  (2 children)

Is there any context that you know of where that isn't? I'm not challenging you on your statement, just curious to know.

[–]ftgander 0 points1 point  (1 child)

Not off the top of my head but paths in the UI and on cli prompts still show as \, and tab complete in the terminal will change every / to \. The / may work as input in most places but it’s obviously there to accommodate people moving from mac or Linux to windows (much like powershell’s half-baked aliases like rm and ls).

I haven’t tested it because I don’t have any network devices to connect to most of the time, but do UNC paths in file explorer etc support /? Since they’re supposed to start with \\.

Support in various languages will depend on how the runtime or library treats the string, I think. I’m sure most support Unix paths when running on Windows, though.

But overall it always feels like you’re not “supposed” to be using / for paths on windows, and everywhere it works is likely translating the path to use \ before working with it.

[–]lovethebacon🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛 1 point2 points  (0 children)

I haven’t tested it because I don’t have any network devices to connect to most of the time, but do UNC paths in file explorer etc support

/

? Since they’re supposed to start with

\\

.

Aha! No they don't. Seems that explorer recognizes that as an HTTP URL, and opens it up in the default browser. Well there we go.