Shell | type type |
zsh | type is a shell builtin |
bash | type is a shell builtin |
dash | type is a shell builtin |
tcsh | type is a shell builtin |
type is an alias for 'whence -v' |
type
命令用于查看某个命令的类型
。
type COMMAND_NAME
type which
type command
if command -v which > /dev/null && [ "$(type which)" = "which is a shell builtin" ]; then
echo "this is zsh $ZSH_VERSION";
elif command -v caller > /dev/null && [ "$(type caller)" = "caller is a shell builtin" ]; then
echo "this is bash $BASH_VERSION";
elif command -v enum > /dev/null && [ "$(type enum)" = "enum is a special shell builtin" ]; then
echo "this is ksh $KSH_VERSION";
else
echo "this is ash";
fi
依据:
Shell | 特有的内部命令 | 特有的环境变量 |
zsh | which | ZSH_VERSION |
bash | caller | BASH_VERSION |
ksh | enum | KSH_VERSION |
tcsh | builtins | version 、tcsh |