bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in mkdir: Misleading Error Message


From: Paul Eggert
Subject: Re: Bug in mkdir: Misleading Error Message
Date: Tue, 07 Sep 2004 19:42:30 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Dmytro Taranovsky <address@hidden> writes:

> As far as I know, mkdir prints "No such file or directory" only when the
> parent directory does not exist

Only if by "not exist" you mean "mkdir() fails with errno==ENOENT",
which is a bit circular.  For example:

   $ rm -f x y
   $ ln -s x y
   $ ls -l x y
   ls: x: No such file or directory
   lrwxrwxrwx  1 eggert eggert 1 2004-09-07 19:33 y -> x
   $ mkdir y/d
   mkdir: cannot create directory `y/d': No such file or directory

Here, a more accurate error message would be something like "y exists,
but it's a dangling symbolic link, so the name y/d doesn't work".
That'd take a bit of work to generate.  Or how about this one:

   $ rm -f x
   $ mkdir x/y/z
   mkdir: cannot create directory `x/y/z': No such file or directory

Here the real problem is that x doesn't exist, not that x/y doesn't
exist; and mkdir would have to root around and discover this in order
to avoid the misleading error message "x/y doesn't exist".

Here's another one:

   $ mkdir ''
   mkdir: cannot create directory `': No such file or directory

A different case entirely.  There are probably other cases but I hope
you get the idea.  Fixing all this to produce a "nice" message, that
is reliable in general, would be a bit of work.

The fundamental problem here is that errno==ENOENT is overloaded,
but this is more the fault of mkdir() than of the "mkdir" command.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]