summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-11-10 18:54:19 +0000
committerJim Meyering <jim@meyering.net>2000-11-10 18:54:19 +0000
commitb3324ca1965535fb3ab01c110350c6ebdede434a (patch)
tree90fd576936d3b279602be2fdcbe3c698a4241d95 /src
parentc90aa4af6c0a35797a6b7cadee1c34223120194f (diff)
downloadcoreutils-b3324ca1965535fb3ab01c110350c6ebdede434a.tar.xz
(main): Interpret a lone numeric argument of 8 or 10
digits as a file name, rather than as a date/time in the obsolescent `MMDDhhmm[YY]' format. Reported by Wenjun Zheng.
Diffstat (limited to 'src')
-rw-r--r--src/touch.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/touch.c b/src/touch.c
index a10575146..df595ae8e 100644
--- a/src/touch.c
+++ b/src/touch.c
@@ -334,7 +334,9 @@ main (int argc, char **argv)
date_set++;
}
- if (!date_set && optind < argc && !STREQ (argv[optind - 1], "--"))
+ /* The obsolescent `MMDDhhmm[YY]' form is valid IFF there are
+ two or more non-option arguments. */
+ if (!date_set && 2 <= argc - optind && !STREQ (argv[optind - 1], "--"))
{
newtime = posixtime (argv[optind], PDS_TRAILING_YEAR);
if (newtime != (time_t) -1)