How do I tell what type my shell is

2019-03-14 23:56发布

How can I tell what type my shell is? ie, whether it's traditional sh, bash, ksh, csh, zsh etc.

Note that checking $SHELL or $0 won't work because $SHELL isn't set by all shells, so if you start in one shell and then start a different one you may still have the old $SHELL.

$0 only tells you where the shell binary is, but doesn't tell you whether /bin/sh is a real Bourne shell or bash.

I presume that the answer will be "try some features and see what breaks", so if anyone can point me at a script that does that, that'd be great.

标签: shell unix posix
7条回答
欢心
2楼-- · 2019-03-15 01:01

Try to locate the shell path using the current shell PID:

ps -p $$

It should work at least with sh, bash and ksh.

查看更多
登录 后发表回答