Bug 238065 - Regression in date(1)
Summary: Regression in date(1)
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-23 03:38 UTC by Greg Rivers
Modified: 2019-06-01 12:11 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Rivers 2019-05-23 03:38:42 UTC
I noticed recently that `date -r` no longer works:

$ freebsd-version -uk
12.0-RELEASE-p4
12.0-RELEASE-p5

(11.2-RELEASE also seems to be affected)

$ date +%s
1558581709

$ date -r 1558581709
date: -r: unknown option
Usage: date [-aceEiLlmnRsuz] [-d date] [-f format] [-p format] [-T type]
            [-U scale] [ +format | date ... | file ... ]

Interestingly, the above usage message does not match the message compiled into the date binary:

$ strings /bin/date | fgrep -i usage
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]

But the manual page still says that `date -r` should work as expected:

     -r seconds
             Print the date and time represented by seconds, where seconds is
             the number of seconds since the Epoch (00:00:00 UTC, January 1,
             1970; see time(3)), and can be specified in decimal, octal, or
             hex.

In fact the manual page matches the compiled in usage string and not the usage message printed when `date -r` errors out. Strange.

I suspect that Revision 282608 <https://svnweb.freebsd.org/base?view=revision&revision=282608> may have something to do with this.
Comment 1 Greg Rivers 2019-05-23 03:49:38 UTC
Sorry, I think I spoke too soon. The problem appears to be with my shell (ksh93), which was recently updated. Even though ksh says it's running /bin/date:

$ whence date
/bin/date

that doesn't appear to be the case:

$ date -r 1558581709
date: -r: unknown option
Usage: date [-aceEiLlmnRsuz] [-d date] [-f format] [-p format] [-T type]
            [-U scale] [ +format | date ... | file ... ]

$ /bin/date -r 1558581709
Wed May 22 22:21:49 CDT 2019

Sorry for the noise!
Comment 2 Conrad Meyer freebsd_committer 2019-05-23 04:15:17 UTC
I was going to say, the mismatch in usage text suggests that 'date' is not '/bin/date'.  /bin/date's -r implementation looks fine to me.
Comment 3 IPTRACE 2019-05-30 16:32:48 UTC
Please reopen the bug. I see the problem exists due to KornShell update.
To avoid this for sure it's desirable to insert absolute path to date command (/bin/date).


user@serv:~ % date -r
date: option requires an argument -- r
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
            [-I[date | hours | minutes | seconds]]
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

user@serv:~ % /bin/date -r
date: option requires an argument -- r
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
            [-I[date | hours | minutes | seconds]]
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

user@serv:~ % ksh -c "date -r"
date: -r: unknown option
Usage: date [-aceEiLlmnRsuz] [-d date] [-f format] [-p format] [-T type] [-U scale] [ +format | date ... | file ... ]

user@serv:~ % ksh -c "whereis date"
date: /bin/date /usr/share/man/man1/date.1.gz /usr/src/bin/date

user@serv:~ % sh -c "whereis date"
date: /bin/date /usr/share/man/man1/date.1.gz /usr/src/bin/date

user@serv~ % ksh -c "stat -x /bin/date"
  File: "/bin/date"
  Size: 36080        FileType: Regular File
  Mode: (0555/-r-xr-xr-x)         Uid: (    0/    root)  Gid: (    0/   wheel)
Device: 0,98   Inode: 561849    Links: 1
Access: Thu May 30 18:16:35 2019
Modify: Wed Dec 26 00:10:24 2018
Change: Sun May 19 11:03:28 2019

user@serv~ % sh -c "stat -x /bin/date"
  File: "/bin/date"
  Size: 36080        FileType: Regular File
  Mode: (0555/-r-xr-xr-x)         Uid: (    0/    root)  Gid: (    0/   wheel)
Device: 0,98   Inode: 561849    Links: 1
Access: Thu May 30 18:16:35 2019
Modify: Wed Dec 26 00:10:24 2018
Change: Sun May 19 11:03:28 2019

user@serv~ % ksh -c "/bin/date -r"
date: option requires an argument -- r
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
            [-I[date | hours | minutes | seconds]]
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
Comment 4 IPTRACE 2019-05-30 16:46:34 UTC
user@serv:~ % ksh -c "which date"
/bin/date

user@serv:~ % sh -c "which date"
/bin/date
Comment 5 Greg Rivers 2019-05-30 16:49:17 UTC
(In reply to IPTRACE from comment #3)
The problem is clearly with the ksh93 update. I think it has to do with builtin functions. I see a similar problem with the `tail -F` command too.

I don't think it makes sense to reopen this particular bug, as there is nothing with /bin/date. We should perhaps open a bug against ksh93 instead.
Comment 6 IPTRACE 2019-05-30 18:41:21 UTC
Ok, just created new bug report.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238248