]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(main): Interpret a lone numeric argument of 8 or 10
authorJim Meyering <jim@meyering.net>
Fri, 10 Nov 2000 18:54:19 +0000 (18:54 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 10 Nov 2000 18:54:19 +0000 (18:54 +0000)
digits as a file name, rather than as a date/time in the obsolescent
`MMDDhhmm[YY]' format.  Reported by Wenjun Zheng.

src/touch.c

index a105751462d3d480d3af7ab7614c71f41110529e..df595ae8ec43c8bfc1d410fb7ae70e33870153a8 100644 (file)
@@ -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)