DaveC
DaveC

Reputation: 167

Bug in GnuWin32 port of mkdir?

I seem to have come across a wierd behaviour of GnuWin32's mkdir (from here):

C:\sandbox>"C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE" --verbose -p Q:/scratch/foo/bar
C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE: created directory `Q:/scratch'
C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE: created directory `Q:/scratch/foo'
C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE: created directory `Q:/scratch/foo/bar'

In the above, the current drive is C and the target drive is Q. As expected, the hierarchy gets created in Q:/scratch/foo/bar

Now, almost the same example but the current and the target drives are both C.

C:\sandbox>"C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE" --verbose -p C:/scratch/foo/bar
C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE: created directory `C:/scratch'
C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE: created directory `C:/scratch/foo'
C:\Program Files (x86)\GnuWin32\bin\mkdir.EXE: created directory `C:/scratch/foo/bar'

mkdir's output looks right and very predictable. However, nothing really gets created at C:/scratch/foo/bar. Rather, the directory hierarchy gets created using the current directory as a root, i.e. what gets created is C:/sandbox/scratch/foo/bar

Can anyone confirm ? Is this a bug ? I would look at the source code if I had the time but....

Does anyone know of a more recent version of CoreUtils than 5.3.0 that's been ported to Win32 ?

Upvotes: 0

Views: 102

Answers (1)

DaveC
DaveC

Reputation: 167

Looks like a small bug indeed. It seems GnuWin32's port doesn't like the forward slash after the colon following the drive letter. Using backslashes it behaves correctly with both

C:\sandbox> mkdir --verbose -p Q:\scratch/foo/bar

and

C:\sandbox> mkdir --verbose -p C:\scratch/foo/bar

But (as reported) when using forward slashes, it only behaves correctly with

C:\sandbox> mkdir --verbose -p Q:/scratch/foo/bar

(in the above, note the target is on a different drive than the prompt) but not with

C:\sandbox> mkdir --verbose -p C:/scratch/foo/bar

(in the above, note the target is on the same drive as the prompt)

The really old mkdir port from UnxUtils has the correct behaviour all the time. That's the only working alternative I could find.

Upvotes: 0

Related Questions