Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: Login shell? Message-ID: <844@philmds.UUCP> Date: 24 Oct 88 18:40:28 GMT Article-I.D.: philmds.844 References: <314@uplog.se> <842@philmds.UUCP> <11@elgar.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 42 In article <11@elgar.UUCP> ag@elgar.UUCP (Keith Gabryelski) writes: |In article <842@philmds.UUCP> leo@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.