which/type & built-ins

Richard A. O'Keefe ok at quintus.UUCP
Mon Jan 1 13:44:53 AEST 1990


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?

The manual page for csh says
     which [ filename ] ...
	  which takes a list of names and looks for the files which
	  would be executed had these names been given as commands.
(Should be    ^^^ "would have been", such grammar!)
which makes it clear that "which if" isn't supposed to recognise "if"
as a command.  I don't quite see why; surely it would be easy for
/usr/ucb/which to execute an appropriate switch() after everything
else has failed.

The manual page for sh says
     type [ name ... ]
	  For each name, indicate how it would be interpreted if
	  used as a command name.
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"?



More information about the Comp.unix.questions mailing list