From: Jim Meyering Date: Wed, 17 Apr 2002 08:49:27 +0000 (+0000) Subject: (touch): Don't report errors for nonexistent files X-Git-Tag: SH-UTILS-2_0_12~126 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ccf99a6d4ceb93cf1bd3f2be4103320beaba6d59;p=thirdparty%2Fcoreutils.git (touch): Don't report errors for nonexistent files when --no-create is in effect. Based on a patch from TAKAI Kousuke. --- diff --git a/src/touch.c b/src/touch.c index 9ede5dd1e9..1d43c300bf 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; }