Project

General

Profile

Bug #3754

ksh93 interposes builtins over real commands which aren't ksh93-based

Added by Rich Lowe over 6 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
cmd - userland programs
Start date:
2013-04-30
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

When ksh93 integrated, it was supposed to only interpose over real commands based on $PATH if the real command was implemented by ksh93

That is, a path lookup of "/bin/paste" would use the builtin, because the actual "/bin/paste" used the ksh93 libcmd anyway.

That isn't what happened. ksh93 will interpose over /bin (but not /usr/bin) a whole bunch of builtins of which we have our own implementation, an obvious example is head(1)

$ builtin | grep head
...
/bin/head
$ PATH=/bin:$PATH
$ which head
/bin/head
$ head -?
Usage: head [-qv] [-n lines] [-c chars] [-s skip] [ file ... ]
$ /bin/head -?
/bin/head: illegal option -- ?
usage: head [-q] [-v] [-n #] [-c #] [-#] [filename...]

You'll note just from their behaviour that they're actually different, that which(1) is lying to me, and that I'm pretty damn angry about it.

History

#1

Updated by Gary Mills over 6 years ago

which(1) does lie to you, but that's because it's intended for csh, not ksh. For ksh, you should use whence(1) instead. In the example you cite, the result is the same.
$ whence head
/usr/bin/head
$ head -?
Usage: head [-qv] [-n lines] [-c chars] [-s skip] [ file ... ]
$ /bin/head -?
/bin/head: illegal option -- ?
usage: head [-n #] [-#] [filename...]
$ /usr/bin/head -?
/usr/bin/head: illegal option -- ?
usage: head [-n #] [-#] [filename...]

#2

Updated by Irek Szczesniak over 6 years ago

If you read PSARC/2006/550 you notice the discussion about builtins. Builtins are allowed to interpose as long as their specification is compatible to the "native" version. Of course, long-term plan of both Tims (Marsland and Sparlin) was to get rid of the native versions and use the code from AST/libcmd to move to an architecture similar to GPL's busybox.

Also available in: Atom PDF