1
Consider the following commands given from a cmd prompt:
D:\test>cd D:/
D:\>cd /test
D:\test>pushd D:/
The syntax of the command is incorrect.
D:\test>pushd "D:/"
D:\>popd
D:\test>cd ..
D:\>pushd /test
The syntax of the command is incorrect.
D:\>pushd "/test"
The syntax of the command is incorrect.
D:\>pushd "D:/test"
D:\test>
It seems that cd
process correctly slashes /
in general, while pushd
only accepts them only if at the same time:
- The argument is quoted
- The full path is given
Does this correspond to truth? Is it documented anywhere?
The funny thing is that changing to the
/?
directory usingcd /?
can give you some help with thecd
command – infixed – 2016-04-01T13:07:03.800@infixed Yep! :) And you cannot change to a hypothetical folder named
D
by doingcd /D
as that is a validcd
option. – Antonio – 2016-04-01T13:12:26.530It looks like you are using the
cmd
shell in Microsoft's Windows, therefore you have to put the slash the wrong way around. (This is because of a historical accident, there the slash was used to give options. It seemed like a good idea at the time, as Microsoft had not heard of directories at this time, (or of windowing systems, or networks)). – ctrl-alt-delor – 2016-04-01T21:22:44.993Windows doesn’t really do forward slashes. They’re traditionally used to indicate switches on the command line. So while your question might be academically interesting, it’s not really about a problem. – Daniel B – 2016-04-01T21:25:14.497
@DanielB I wonder then why they didn't simply implement functions to give error in case
/
was used (without a valid option). My use case concerns paths generated bycmake
to be used in a configure file generating a batch script. – Antonio – 2016-04-01T22:56:31.797