NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

standards/59888: touch(1) parses dates wrongly



>Number:         59888
>Category:       standards
>Synopsis:       touch(1) parses dates wrongly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    standards-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 04 15:40:01 +0000 2026
>Originator:     Taylor R Campbell
>Release:        10, 9, ...
>Organization:
The DateBSD Touchination
>Environment:
>Description:

	touch(1) does not correctly implement the POSIX.1-2008 `-d'
	syntax for dates (same in POSIX.1-2024, I think):

	https://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html

-d  date_time
    Use the specified date_time instead of the current time. The option-argument shall be a string of the form:

    YYYY-MM-DDThh:mm:SS[.frac][tz]

    or:

    YYYY-MM-DDThh:mm:SS[,frac][tz]

    where:

        YYYY are at least four decimal digits giving the year.

        MM, DD, hh, mm, and SS are as with -t time.

        T is the time designator, and can be replaced by a single <space>.

        [.frac] and [,frac] are either empty, or a <period> ( '.' ) or a <comma> ( ',' ) respectively, followed by one or more decimal digits, specifying a fractional second.

        [tz] is either empty, signifying local time, or the letter 'Z', signifying UTC. If [tz] is empty, the resulting time shall be affected by the value of the TZ environment variable.

    If the resulting time precedes the Epoch, the behavior is implementation-defined. If the time cannot be represented as the file's timestamp, touch shall exit immediately with an error status.

>How-To-Repeat:

	$ touch -d 1970-01-01T01:01:01Z pkg_summary.gz
	touch: Could not parse `1970-01-01T01:01:01Z'
	$ touch -d 1970-01-01T01:01:01 pkg_summary.gz
	$ ls -lT pkg_summary.gz
	-rw-r--r--  1 riastradh  riastradh  0 Dec 31 18:01:01 1969 pkg_summary.gz

>Fix:

	Pull up kre's February 2024 changes to src/usr.bin/touch.



Home | Main Index | Thread Index | Old Index