tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: interactive shell detection in shrc



Steffen Nurpmeso wrote in
 <20240926233234.MwKivWJi@steffen%sdaoden.eu>:
 |Greg A. Woods wrote in
 | <m1stwmt-0036s2C@more.local>:
 ||At Tue, 24 Sep 2024 00:56:40 +0200, Steffen Nurpmeso <steffen%sdaoden.eu@localhost> \
 ...
 ||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)


Home | Main Index | Thread Index | Old Index