Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does the cmd.exe shell on Windows fail with paths using a forward-slash ('/'') path separator?
    primarykey
    data
    text
    <p>Just when I'd thought I'd seen it all with Windows path issues, I've now encountered a case that only fails when '/' (forward-slash) is used as the path separator is used:</p> <pre><code>C:\temp\tcbugs&gt;mkdir "dir1 with spaces" C:\temp\tcbugs&gt;echo hi &gt; "dir1 with spaces"\foo.txt C:\temp\tcbugs&gt;type "dir1 with spaces\foo.txt" hi C:\temp\tcbugs&gt;type "dir1 with spaces/foo.txt" The system cannot find the file specified. </code></pre> <p>What is particularly interesting about this is that it appears to be specific to the cmd.exe shell and doesn't occur in PowerShell (nor presumably in the win32 API):</p> <pre><code>PS C:\temp\tcbugs&gt; type 'dir1 with spaces/foo.txt' hi </code></pre> <p>Another point of interest is that changing directories with 'cd' and using '/' used as a path separator with cmd.exe does work:</p> <pre><code>C:\temp\tcbugs&gt;mkdir dir2_no_spaces C:\temp\tcbugs&gt;cd ./dir2_no_spaces C:\temp\tcbugs\dir2_no_spaces&gt;cd .. </code></pre> <p>Yet, I can't find any reference to this particular problem anywhere online nor in MSDN's commonly cited documentation:</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx">Naming Files, Paths, Namespaces</a></p> <p>Which leads me to ask: why does this happen, and is there a definitive source which documents this quirk?</p> <p><strong>UPDATE:</strong></p> <p>dbenham points out that the problem is present regardless of whether spaces are in a directory name, so removed reference to it in the title and question body. Also added an example of 'cd ./' that works, while other commands don't.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload