which/type & built-ins
Ruud Harmsen
ruud at targon.UUCP
Thu Jan 4 19:27:56 AEST 1990
In article <1297 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
>Does anyone know why the C shell command "which" (ok, /usr/ucb/which)
>and the Bourne shell command "type" don't understand built-in commands?
> [stuff deleted]
>
>This certainly looks to me as though "type if" SHOULD succeed, and
>"type type" _does_. So why does "type while" say "while not found"
>rather than "while is a shell builtin"?
The point is that "if", "while" etc. are keywords, i.e. lexical units that
make the syntax of the shell command language. They do not do anything
themselves, but rather control the way other things are done, or going to
be done.
"cd", "type" and (often) "test" etc. are commands that perform some action,
and which happen to have been implemented without creating a separate process.
(In the case of "cd", it has to be, in the other cases, speed is probably
the only reason).
So I would not object to type recognizing "while", but then as a keyword,
not as a builtin *command*.
More information about the Comp.unix.questions
mailing list