[comp.sys.apollo] Korn shell, mailing lists

buchs@MAYO.EDU (Kevin J. Buchs) (07/06/90)

I am starting to write korn shell scripts.  I would like to disable the
execution of the file pointed to by the ENV parameter when entering the
script.  How is this done?  I can do it in a csh script by starting the
file with:

	#!/bin/csh -f

I tried this in the korn script but, anything I put in causes it to go
into an interactive shell:

	#!/bin/ksh -DENV=
	#!/bin/ksh -s -DENV=
	#!/bin/ksh -DENV="/dev/null"

Even defining another parameter this way causes an interactive shell to
start:

	#!/bin/ksh -DANOTHER=


Is there a mailing list (not newsgroup) for which this question might be
more appropriate?

Does anyone know if a HP mailing list exists that is fed from
comp.sys.hp?

Thanks.

-------------------------------------------------------------
Kevin Buchs          Internet: buchs@mayo.edu
Mayo Foundation              Is this my life or is it just an
Rochester, MN 55905          incredible, high-speed, simulation?
(507) 284-0009                         -S. R. Cleaves
-------------------------------------------------------------

pbm@hpfcdc.HP.COM (Peter McLain) (07/10/90)

>I am starting to write korn shell scripts.  I would like to disable the
>execution of the file pointed to by the ENV parameter when entering the
>script.  How is this done?

    You can turn off the processing of the ENV file for non-interactive
    shells with the following in your ~/.profile:

		export ENV='${FILE[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}'
		export FILE=$HOME/.envfile

    The idea is that ${FILE[0]} = "$HOME/.envfile" and ${FILE[1]} = "".
    ENV evaluates to the former for interactive shells and the latter
    for non-interactive shells.  The parameter "-" will contain an 'i'
    for an interactive shell (try "echo $-" in a shell script and at the
    prompt).  All the work is done in the subscript to FILE in the 
    first line above:

	(_$-=1)               set parameter named _$- to 1 (e.g.,
                              set _ism=1 for an interactive shell and
                              set _h=1 for a non-interactive shell).

	(_=0)                 set parameter named _ to 0 (we need this
                              since we may reference $_ in the next step).

	(_$-!=_${-%%*i*})     "${-%%*i*}" evaluates to "" if $- contains
                              an 'i', and to $- otherwise.  For an interactive
                              shell the check is if "_$-" is NOT the same as
                              "_$-" (false) and for a non-interactive shell the
                              check is if "_$-" is not the same as "_" (true).
                              So this evaluates to 1 (false) for interactive
                              shells, and 0 (true) for non-interactive shells.


    So for interactive shells you get:

	${FILE[1+0-1]} = ${FILE[0]} = $HOME/.envfile

    and for non-interactive shells you get:

	${FILE[1+0-0]} = ${FILE[1]} = ""

---------------------
Peter McLain                                          Hewlett-Packard
                                                      3404 East Harmony Road
pbm%hpfclg@hplabs.HP.COM                              Fort Collins
UUCP: hplabs!hpfcla!pbm                               CO          80525-9599