which/type & built-ins
Robert J. Reschly Jr.
reschly at BRL.MIL
Tue Jan 2 10:17:07 AEST 1990
Richard,
You say:
> 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 "which" command is an independent program (actually a C-shell
script) which can be called from any command interpreter. Since the
various command interpreters offer differing sets of built-in commands,
"which" cannot presume to know anything about built-in commands.
Additionally there is no reasonable way for "which" to learn this
information.
> 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.
Resulting in "which blurfle" responding with "blurfle is a shell
built-in"? What action would you have the switch() branch take? Note
that another failure mode for "which" involves using a shell other than
/bin/csh while having a .cshrc in your home directory. If this .cshrc
defines any aliases, "which" will gladly report them even though they are
probably inappropriate.
As for "type", I have no good answers. Given that "type type"
reports itself as a shell built-in it should be able to report on other
built-ins. My current shell of choice, "tcsh" handles this operation
correctly.
Later,
Bob
--------
Internet: reschly at BRL.MIL (or BRL.ARMY.MIL) Phone: (301)278-6808 AV: 298
UUCP: ...!{{cmcl2,nlm-mcs,husc6}!adm,smoke}!reschly
Postal: Robert J. Reschly Jr.
U.S. Army Ballistic Research Laboratory
Systems Engineering and Concepts Analysis Division
Networking and Systems Development Team
ATTN: SLCBR-SE-A (Reschly)
APG, MD 21005-5066 (Hey, *I* don't make 'em up!)
**** For a good time, call: (303) 499-7111. Seriously! ****
More information about the Comp.unix.questions
mailing list