Bug 238248

Summary: shells/ksh93: Uses improper date command after ksh93-20141224 update
Product: Ports & Packages Reporter: IPTRACE <arkadiusz.majewski>
Component: Individual Port(s)Assignee: Cy Schubert <cy>
Status: Closed FIXED    
Severity: Affects Many People CC: cy, gcr, saper
Priority: --- Keywords: needs-qa, regression
Version: LatestFlags: bugzilla: maintainer-feedback? (saper)
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238065

Comment 1 Marcin Cieślak 2019-05-30 21:26:39 UTC
ksh93 is a part of a larger tookit called AST ( AT&T Software Technology ) and along with it there are some utilities built-in with the shell:

> whence -v date
date is a shell builtin version of /bin/date
> whence -a date
date is a shell builtin version of /bin/date

There are quite a few of them:

builtin | grep /opt/ast/bin

> builtin | grep /opt/ast/bin | sed 's,/opt/ast/bin/,,' | paste - - - -
basename        cat     chgrp   chmod
chown   cksum   cmp     comm
cp      cut     date    dirname
egrep   expr    fds     fgrep
fmt     fold    getconf grep
head    iconv   id      join
ln      logname ls      md5sum
mkdir   mkfifo  mktemp  mv
od      paste   pathchk pids
readlink        realpath        rev     rm
rmdir   sha1sum sha256sum       sha2sum
sha384sum       sha512sum       stty    sum
sync    tail    tee     tr
tty     uname   uniq    vmstate
wc      xargs   xgrep

(in reality, not all of them are availbe - chmod is but chown isn't).

Here is an excerpt from the description

                The stanadlone ksh is statically linked with the ast libcmd
                library which provides several builtin versions of /bin
                commands. "builtin | grep /opt/ast/bin" lists the libcmd
                builtins on the standard output. /opt/ast/bin/FOO accesses
                the FOO builtin, whether the /opt/ast/bin directory exists
                or not. "builtin FOO" allows /opt/ast/bin/FOO to be accessed
                as FOO, bypassing the $PATH setting. To enable all libcmd
                builtins do one of the following:
                  (a) create the directory /opt/ast/bin and the file
                      /opt/ast/bin/.paths with this line
                      and place /opt/ast/bin before /bin and /usr/bin in $PATH
                      (this will affect all ksh subshells and scripts)
                  (b) run "builtin $( builtin | sed -e '/\//!d' -e 's,.*/,,' )"
                      (this will affect only the current shell)
                Some scripts may run significantly faster with libcmd builtins

The point here is to have a consistent set of mostly used utilities and to make ksh93 run much faster.

I think I have inadvertedly changed the way ksh93 was built and that might have enabled the builtins. Need to check.

I guess the new port (formerly ksh93-devel) does not have this issue.
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2019-06-01 12:11:47 UTC
Re-classifying/opening the original bug 238065 would have been preferred, but since this has already been created, we'll carry on here.
Comment 3 Greg Rivers 2019-06-03 19:49:41 UTC
(In reply to Marcin Cieślak from comment #1)
I figured it was something like that. I had seen unexpected results from date, fgrep, and tail.

After yesterday's ksh93 update, the problems are gone for me.

Jun  3 04:28:19 hhh pkg[22582]: ksh93 upgraded: 20141224 -> 2020.0.0.a1,1

Now I see:

$ whence -v date
date is a tracked alias for /bin/date

$ whence -a date
date is a tracked alias for /bin/date

Comment 4 Marcin Cieślak 2019-06-06 09:09:53 UTC
Good question whether this is a bug or feature. I think we should close this since this no longer occurs with ksh93 alpha.
Comment 5 Cy Schubert freebsd_committer 2019-06-11 11:46:01 UTC
Fixed as up update to 2020.0.0.