4 ms·
Are there contexts where the backslash is still required? I've been using the forward slash in Windows for years. It works from Python, it works from the comman
by gdulli 5y ago
Are there contexts where the backslash is still required? I've been using the forward slash in Windows for years. It works from Python, it works from the command prompt, it works in Explorer. But I don't know if that means it's completely redundant or if some places still require it.
- Something1234 5y agoIt doesn't tab complete the path if you use forward slash in windows batch. I think forward slash works right in PowerShell, but I might be mistaken.
- mshockwave 5y agoit works just fine in PowerShell and the new Windows Terminal but yeah, I doubt CMD will do auto-complete for you w/ forward slash
- EvanAnderson 5y agoIt will not. It completes out of the current directory when trying to TAB-complete following a slash.
- infogulch 5y agoPowershell will autocomplete forward-slash paths and convert them to back slashes.
- dfawcus 5y agoAt the API level, both '/' and '\' have been accepted since sub-directories were added to DOS. It was only ever at the UI (command prompt), and in how some programs converted inputs and outputs where '\' was necessary, as the knowledge about '/' being usable wasn't all that widespread. What used to peeve me was C source on DOS development environments with lines like: #include "path\\to\\file.h" When the following always seemed to work (with the compilers I used): #include "path/to/file.h" Or at least it did with Borland compilers.
- edgyquant 5y agoThis post isn’t about file paths but command line arguments
- electroly 5y agoBecause the forward slash is used for command line flags, there can be ambiguity when using forward slashes in paths that does not exist if using backslashes. Consider a directory on your root C: drive called "D". In a command prompt: cd \D <-- This takes you to the C:\D\ directory. cd /D <-- This is an error because /D is a flag.
- paulmooreparks 5y agoTrue, but quoting the path will work: cd "/D"
- adtac 5y agoHow? Wouldn't the program's argv see the same string with and without quotes? Or is that just a *nix thing?
- schroeding 5y agocd is a built-in of the shell / cmd, not an application, it does not use argv, AFAIK. It should, as you said, not work for normal applications
- johnny22 5y agonope. I read an article about this when i accidentally broke the arg parsing for wildcards. worked fine in linux, but not on windows :(
- int_19h 5y agoIn Win32, argv is not part of the OS process API. The processes get the entire command line as a string, and have to parse it themselves - or, more commonly, leave it up to the C runtime. But in this case, I don't think it matters.
- DrBazza 5y agoThis is interesting regarding args. https://nullprogram.com/blog/2022/02/18/ https://nullprogram.com/blog/2022/02/18/
- joshuaissac 5y agoThey are still needed in UNC paths like \\server\...\.
- dgrunwald 5y agoUNC paths like //server/share/ are perfectly fine.
- deleted 5y ago[deleted]
- joshuaissac 5y agoI tried it in Windows Explorer on Windows 10, and it just launches the browser for me instead of opening the folder.
- EvanAnderson 5y agoCMD and Windows Explorer don't like that. Powershell handles it fine.
- edflsafoiewq 5y agoI think \\?\ paths require backslashes.
- jaclaz 5y agoAlso, the Registry. And BTW .reg files need to double the backslash because it is parsed as an escape character.
- layer8 5y agoIt's required when passing a path as argument to Explorer. That is, when you type "explorer C:/" in the Run box or on the command line, Explorer opens in the default folder instead of in C:\. That's probably because Explorer also accepts URLs, so "explorer file://C:/" does work. For some reason, the Explorer address bar behaves differently.
- int_19h 5y agoAny / that occurs in an unquoted command line argument is going to be treated as a separator, so you've effectively invoked "explorer C: /".