Re: interactive shell detection in shrc

Steffen Nurpmeso <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <20240926234813.hgDdmZkJ@steffen%sdaoden.eu>
Steffen Nurpmeso wrote in
 <20240926233234.MwKivWJi@steffen%sdaoden.eu>:
 |Greg A. Woods wrote in
 | <[email protected]>:
 ||At Tue, 24 Sep 2024 00:56:40 +0200, Steffen Nurpmeso <[email protected]> \
 ...
 ||To work around this I do the following:
 ||
 || _interactive=false
 || case "$-" in
 || *i*)
 ||  _interactive=true
 ||  ;;
 || esac
 || case "$0" in
 || -*)
 ||  _interactive=true
 ||  ;;
 || esac
 || if ${_interactive}; then
 ||: ... do interactive setup
 || else
 ||: ... do script-mode setup
 || fi
 || unset _interactive
 |
 |This looks very much interesting, except that i would insist on
 |being afraid on that "if EXPANSION" thing.  I mean, i know, in

I changed it to (but tab indent; private credits to you..)

  if [ -z "$___SHRC" ]; then
    if [ "$-" != "${-%i*}" ] || [ "$-" != "${-%m*}" ] || [ -z "${0%-*}" ]; then
      ___shrc
    fi
    ___SHRC=y
  fi

  ...

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.