From ccf99a6d4ceb93cf1bd3f2be4103320beaba6d59 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 17 Apr 2002 08:49:27 +0000 Subject: (touch): Don't report errors for nonexistent files when --no-create is in effect. Based on a patch from TAKAI Kousuke. --- src/touch.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3-70-g09d2