What's the preferred way to determine if a given ksh invocation is running an interactive shell?
I have some commands in an ENV
file that I would like to skip for non-interactive ksh invocations (e.g. when executing a shell script).
I've seen suggesting ranging from:
if [[ $- = *i* ]]; then
# do interactive stuff
fi
...to not even sourcing .kshrc
unless the shell is determined to be interactive using this cryptic incantation:
ENVIRON=$HOME/.kshrc export ENVIRON
ENV='${ENVIRON[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}' export ENV