tech-userlevel archive

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

Re: interactive shell detection in shrc



    Date:        Fri, 27 Sep 2024 01:48:13 +0200
    From:        Steffen Nurpmeso <steffen%sdaoden.eu@localhost>
    Message-ID:  <20240926234813.hgDdmZkJ@steffen%sdaoden.eu>

  | I changed it to (but tab indent; private credits to you..)
  |
  |   if [ -z "$___SHRC" ]; then
  |     if [ "$-" != "${-%i*}" ] || [ "$-" != "${-%m*}" ] || [ -z "${0%-*}" ]; then

You want the third test to use %% rather than % or you won't detect
a login shell (presumably interactive) (without -i or -m for some
reason, which seems unlikely in modern times) if its name happens
to contain a '-' character ... -shell-2.7 would become -shell with
your string sub, which is not empty, and -z fails.

kre


Home | Main Index | Thread Index | Old Index