2021-04-10 22:12:47 +0200, Joerg Schilling via austin-group-l at The Open Group:
> "Jan Hafer via austin-group-l at The Open Group" 
> <[email protected]> wrote:
> 
> > For a short recap why: There are `which, type, command, whence, where, 
> > whereis, whatis, hash` used in shells. Worse, the semantics of `which` 
> > is shell-dependent.
> 
> which         is a csh script and unrelated to Bourne or POSIX shells.
>               It therefore cannot give useful results in a standard
>               shell environment.
> 
>               Even worse: On Linux, "which" may be a program with different
>               behavior.

The OS kernel is hardly relevant here. Various Linux-based OSes
use various implementations of "which". On Debian-based systems,
these days, it's implemented as a POSIX sh script (regardless of
whether Linux (most common by far), kFreeBSD, Hurd, Illumos...
is used as the kernel)

> 
> type          is built into the shell since 1976. What problems do you
>               have with it?

No, actually type was added to the Bourne shell in SVR2 released
in 1984, and had that problem that it would not return failure
when failing to find a command (a bug which survived well into
the 90s on some OSes IIRC).

The fact that "which" came first largely explains why it's still
more popular (even if more broken and less useful in shells
other than tcsh/zsh) than "type".

> command               is POSIX standard. What problems do you have with it?

Technically, a "command" builtin was added to zsh first in 1990.
POSIX.2 introduced a "command" builtin with different
semantics for sh in 1992.

> whence                is a ksh specific command and thus non-portable
> 
> where         ??? what is that?

A builtin of tcsh (since 1991) and zsh. In zsh, it's the same as
which -a, "which" being the same as whence -c.

> whereis               does not exist on a typical UNIX system

whereis was added to 3BSD at the same time as which.

> 
> whatis                is a command that behaves like "man -k"
[...]

The type builtin was renamed to whatis in research Unix V8 sh
(1985), based on SVR2's shell and extended.

That's different from 2BSD's whatis command (1979, by Bill Joy,
csh/vi's author) that grep'ed /usr/lib/whatis, a man page
index (itself originally generated by a makewhatis csh script).

Most of that and much more was already mentioned at
https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then
as referenced in the OP's original message.

-- 
Stephane

          • Re... Joerg Schilling via austin-group-l at The Open Group
          • Re... Joerg Schilling via austin-group-l at The Open Group
            • ... shwaresyst via austin-group-l at The Open Group
            • ... Robert Elz via austin-group-l at The Open Group
              • ... Joerg Schilling via austin-group-l at The Open Group
              • ... Chet Ramey via austin-group-l at The Open Group
      • Re: [Shell... Robert Elz via austin-group-l at The Open Group
  • Re: [Shell Command ... Robert Elz via austin-group-l at The Open Group
  • Re: [Shell Command ... Joerg Schilling via austin-group-l at The Open Group
    • Re: [Shell Com... Paul Smith via austin-group-l at The Open Group
    • Re: [Shell Com... Stephane Chazelas via austin-group-l at The Open Group
      • Re: [Shell... Joerg Schilling via austin-group-l at The Open Group
  • Re: [Shell Command ... David A. Wheeler via austin-group-l at The Open Group
    • Re: [Shell Com... Oğuz via austin-group-l at The Open Group
      • Re: [Shell... David A. Wheeler via austin-group-l at The Open Group
        • Re: [S... Oğuz via austin-group-l at The Open Group
          • Re... David A. Wheeler via austin-group-l at The Open Group
            • ... Oğuz via austin-group-l at The Open Group

Reply via email to