Re: interactive shell detection in shrc

Robert Elz <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
    Date:        Fri, 27 Sep 2024 01:48:13 +0200
    From:        Steffen Nurpmeso <[email protected]>
    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
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.