summaryrefslogtreecommitdiff
path: root/src/touch.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-04-17 08:49:27 +0000
committerJim Meyering <jim@meyering.net>2002-04-17 08:49:27 +0000
commitccf99a6d4ceb93cf1bd3f2be4103320beaba6d59 (patch)
treeea37f7def39b152bca3f6398a06881298851fa86 /src/touch.c
parent78ec76159b08125083f57a1e414eee5fdcf69bd9 (diff)
downloadcoreutils-ccf99a6d4ceb93cf1bd3f2be4103320beaba6d59.tar.xz
(touch): Don't report errors for nonexistent files
when --no-create is in effect. Based on a patch from TAKAI Kousuke.
Diffstat (limited to 'src/touch.c')
-rw-r--r--src/touch.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/touch.c b/src/touch.c
index 9ede5dd1e..1d43c300b 100644
--- a/src/touch.c
+++ b/src/touch.c
@@ -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;
}