Login shell?

Leo de Wit leo at philmds.UUCP
Tue Oct 25 04:40:28 AEST 1988


In article <11 at elgar.UUCP> ag at elgar.UUCP (Keith Gabryelski) writes:
|In article <842 at philmds.UUCP> leo at philmds.UUCP (Leo de Wit) writes:
|>1) When I execl("/bin/sh","-sh",(char *)0); from within a C program I
|>also have a shell whose name starts with '-'
|
|Yes, so... Don't do it.

But the '-' option is what I might desperately need, e.g. the C program
is a gate program and I want a .profile to be read when the sh starts.
(yes, I really use this).
A solution for determining the login shell should not say: Ah, but you
mustn't do this, and you mustn't do that or else it fails. It would be
a poor solution otherwise.

|>2) When I exec a shell in my .profile file (for instance if I want my
|>own shell instead of /bin/sh or /bin/csh and don't want to bother my
|>system manager), this shell doesn't start with '-'.
|
|Bother your system manager or ``execl("/bin/sh","-sh",(char *)0); from
|within a C program'' in .profile.

The first thing, ok (if my system manager feels like conforming to
another whim of mine, that is 8-); about the second one, you mean of
course:

execl("/usr/leo/bin/myshell","-sh",(char *)0); from .profile (/bin/sh
I don't need to start thus).

Three remarks:
a) you have to start a separate C program just to accomplish $0 == -sh,
this doesn't sound nice.
b) this new shell you start will read .profile *again*; you will have
to make provisions it doesn't start that C program again
(over and over ...).
c) you still have to fire up a ps to determine whether it's a login
shell, or look at $0. Both methods are fooled by programs whose names
start with '-' (not that there will be that many...). Think for instance
of the symbolic link someone else used to get the '-' in front of the
shell's name; if you by any chance start that shell from your current
shell, it will appear to be a 'login shell'.

          Leo.



More information about the Comp.unix.questions mailing list