2.8 Identifying Login ShellsWhen 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 subshells ( 38.4 ) (started from the login shell) or separate shells started by at ( 40.3 ) , rsh ( 1.33 ) , 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 a shell variable ( 6.8 ) named loginshell :
set loginshell=yes ...csh loginshell=yes ...sh-type shells Now wherever you need to know the type of shell, use tests like:
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. - |
|