I want to check if a command is builtin or a separate program.
In sh
and bash
I use:
$ type <command>
What is the equivalent in csh
?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communitycsh has "which" (which cannot detect sh aliases)
In my environment using tcsh
~ (101) alias
cd cd !* ; ls
q exit
v cursor; xhost + ;resize -s 40 80; unsetenv TERMCAP; screen
xl xlock -nolock -random
y Xearth; run xclock -geometry +1100+0; run nice xload -geometry +950+0 -update 3
~ (102) which y
y: aliased to Xearth; run xclock -geometry +1100+0; run nice xload -geometry +950+0 -update 3
~ (103) type which
type: Command not found.
~ (104) which which
which: shell built-in command.
~ (105) which ls
/bin/ls
~ (106)
csh
on my system, type which
shows that which is /usr/bin/which
and not a builtin, so csh
does in fact not have it. It's a system binary. So YMMV on this.
– DopeGhoti
Aug 12 '16 at 22:46
/usr/bin/type
on xyr system is a shell script that uses the Almquist shell as its interpreter. Xe is thereby running the Almquist shell's builtin type
command and seeing what is built into, and external to, the Almquist shell, rather than the TENEX C shell. This is part of what's so tricky about the whole which
/where
/whence
/whereis
/type
/command -v
mess.
– JdeBP
Aug 13 '16 at 8:38
Simply trying this shows:
$ csh
% type type
type is a shell builtin
So.. yes, you can?
csh
and tcsh
. tcsh 6.18.01 (Astron) 2012-02-14 (x86_64-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec
– DopeGhoti
Aug 12 '16 at 22:47
type
command is an external command as far as the TENEX C shell is concerned: /usr/bin/type
. That external command is a small script that invokes the Almquist's shell's builtin type
command, which prints the message "is a shell builtin". The TENEX C shell would write "shell built-in command".
– JdeBP
Aug 13 '16 at 8:26