]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(touch): Don't report errors for nonexistent files
authorJim Meyering <jim@meyering.net>
Wed, 17 Apr 2002 08:49:27 +0000 (08:49 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 17 Apr 2002 08:49:27 +0000 (08:49 +0000)
when --no-create is in effect.  Based on a patch from TAKAI Kousuke.

src/touch.c

index 9ede5dd1e9b777b9fc55a73d2a06459d8ba25d1f..1d43c300bf2584864a081d0b1f39fd0e1f2c66f9 100644 (file)
@@ -163,7 +163,12 @@ touch (const char *file)
          if (open_errno)
            error (0, open_errno, _("creating %s"), quote (file));
          else
-           error (0, errno, _("failed to get attributes of %s"), quote (file));
+           {
+             if (no_create && errno == ENOENT)
+               return 0;
+             error (0, errno, _("failed to get attributes of %s"),
+                    quote (file));
+           }
          close (fd);
          return 1;
        }
@@ -211,7 +216,11 @@ touch (const char *file)
       if (open_errno)
        error (0, open_errno, _("creating %s"), quote (file));
       else
-       error (0, errno, _("setting times of %s"), quote (file));
+       {
+         if (no_create && errno == ENOENT)
+           return 0;
+         error (0, errno, _("setting times of %s"), quote (file));
+       }
       return 1;
     }