* W.H.Scholten <[EMAIL PROTECTED]> [010113 01:57] wrote:
> Alfred Perlstein wrote:
> 
> [ mkdir ]
> 
> > I'll commit the patch shortly.
> 
> Here's a better patch, it checks for multiple slashes, so mkdir
> /tmp/aa///bb//// will give:
> 
> mkdir: /tmp/aa: No such file or directory
> 
> Also, renamed the function to dirname as it does the same as dirname(1).

Actually, there already exists a function called dirname in libc, dirname(3).

Here's what I'm going to commit:


Index: mkdir.c
===================================================================
RCS file: /home/ncvs/src/bin/mkdir/mkdir.c,v
retrieving revision 1.19
diff -u -u -r1.19 mkdir.c
--- mkdir.c     1999/09/04 03:19:38     1.19
+++ mkdir.c     2001/01/14 03:14:51
@@ -50,6 +50,7 @@
 
 #include <err.h>
 #include <errno.h>
+#include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -108,7 +109,10 @@
                        if (build(*argv, omode))
                                success = 0;
                } else if (mkdir(*argv, omode) < 0) {
-                       warn("%s", *argv);
+                       if (errno == ENOTDIR || errno == ENOENT)
+                               warn("%s", dirname(*argv));
+                       else
+                               warn("%s", *argv);
                        success = 0;
                } else if (vflag)
                        (void)printf("%s\n", *argv);




Does this look ok to you?

-Alfred


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to