-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Steps to reproduce:
_POSIX2_VERSION=199209 POSIXLY_CORRECT=1 touch 01010000 11111111
What happens now: uutils touch creates two files with the creation time set to now:
$ ls -l
-rw-rw-r-- 1 jeffrey jeffrey 0 Jan 20 09:47 01010000
-rw-rw-r-- 1 jeffrey jeffrey 0 Jan 20 09:47 11111111
What I expected to happen: GNU touch uses the first argument as the creation time and the second argument as the file name:
$ ls -l
-rw-rw-r-- 1 jeffrey jeffrey 0 Jan 1 00:00 11111111
Notes: this is causing a failure in the GNU test file tests/touch/obsolescent.sh. The environment variables are necessary, as mentioned in the GNU documentation for this obsolete feature:
On systems predating POSIX 1003.1-2001, touch supports an obsolete syntax, as follows. If no timestamp is given with any of the -d, -r, or -t options, and if there are two or more files and the first file is of the form ‘mmddhhmm[yy]’ and this would be a valid argument to the -t option (if the yy, if any, were moved to the front), and if the represented year is in the range 1969–1999, that argument is interpreted as the time for the other files instead of as a file name. Although this obsolete behavior can be controlled with the _POSIX2_VERSION environment variable (see Standards conformance), portable scripts should avoid commands whose behavior depends on this variable. For example, use ‘touch ./12312359 main.c’ or ‘touch -t 12312359 main.c’ rather than the ambiguous ‘touch 12312359 main.c’.
-- https://www.gnu.org/software/coreutils/manual/html_node/touch-invocation.html