]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(rm): Work around SunOS 4 bug whereby lstat doesn't fail
authorJim Meyering <jim@meyering.net>
Tue, 5 Dec 1995 23:39:06 +0000 (23:39 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 5 Dec 1995 23:39:06 +0000 (23:39 +0000)
when given a zero-length file name argument.  Reported by
Mark Calabretta <mcalabre@atnf.csiro.au>.

src/rm.c

index 7a95032581e9b83f47331e87bee70805a2225898..319aebfca7aca20e68b32dec86dd0c12c1690f47 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -211,7 +211,12 @@ rm (void)
       return 1;
     }
 
-  if (lstat (pathname, &path_stats))
+  if (lstat (pathname, &path_stats)
+      /* The following or-clause is solely for systems like SunOS 4.1.3
+         with (broken) lstat that interpret a zero-length file name
+        argument as something meaningful.  For such systems, manually
+        set errno to ENOENT.  */
+      || (pathname[0] == '\0' && (errno = ENOENT)))
     {
       if (errno == ENOENT && ignore_missing_files)
        return 0;