summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}