Subject: ksh problem... :/
To: None <netbsd-help@NetBSD.ORG>
From: Mason Loring Bliss <mason@acheron.middleboro.ma.us>
List: netbsd-help
Date: 07/27/1998 16:10:25
Hi, all.

I'm trying to add in a variable to ksh - "LOGIN_SHELL" - that scripts can
check to see if they're running inside a login shell or not.

In /usr/src/bin/ksh/misc.c, I see the following:

                /* Set FLOGIN before parsing options so user can clear
                 * flag using +l.
                 */
                Flag(FLOGIN) = (argv[0][0] == '-'
                                || ((p = ksh_strrchr_dirsep(argv[0]))
                                     && *++p == '-'));

However, for some reason, I can't make use of this. After this, I've
put:

                if (Flag(FLOGIN))
                        setstr(global(login_param), "YES");
                else
                        setstr(global(login_param), "NO");

where login_param is defined as follows, at the top of misc.c:

		static const char login_param[] = "LOGIN_SHELL";

When I run ksh, LOGIN_SHELL is *always* set to "NO". It doesn't matter if
I execute ksh from another shell, from an xterm with "-ls" set, manually
as "ksh -" or "ksh -l", or whatever.

Is this FLOGIN behaviour broken, or (more likely) am I missing something
conceptually?

Thanks in advance for clues.

-- 
Mason Loring Bliss..mason@acheron.middleboro.ma.us..acheron.dyn.ml.org/mason
"In the drowsy dark cave of the mind dreams build their nest with fragments
  dropped from day's caravan."--Rabindranath Tagore..awake ? sleep : dream;