5 ms·
Because 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. C
by electroly 5y ago
Because 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/
- electroly 5y agoNo, it doesn't. Try it and see for yourself. Make sure you're using Command Prompt and not PowerShell.
- bejelentkezni 5y agoI made a typo while checking this, and amusingly while neither cd /D nor cd "/D" work, cd "/D? does.