When you first log in to a UNIX system from a terminal, the system usually starts a login shell. This is where you want to do general setup - initialize your terminal, set environment variables, and so on. Here the C shell reads your .login file, and Bourne-type shells read .profile (bash can read others).
Other shells are either(started from the login shell) or separate shells started by , , etc. These shells don't read .login or .profile.
To make it possible to find out which you've got, add the line below to the top of your .login or .profile file: The line sets anamed loginshell:
set loginshell=yes ...csh loginshell=yes ...sh-type shells
Now wherever you need to know the type of shell, use tests like:
if ($?loginshell) ...csh if [ -n "$loginshell" ] ...sh-type shells
This works because only login shells read .login or .profile. The loginshell variable will be defined only in login shells.
Article 7.9 shows another solution.