Re: interactive shell detection in shrc

Steffen Nurpmeso <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <20240927215558.y3ZA--Ng@steffen%sdaoden.eu>
Greg A. Woods wrote in
 <[email protected]>:
 |At Fri, 27 Sep 2024 07:14:46 +0700, Robert Elz <[email protected]> wrote:
 |Subject: Re: interactive shell detection in shrc
 ...
 |Reading POSIX Issue 7 sh(1) just now I note the following text:
 |
 | If the -i option is present, or if there are no operands and the
 | shell's standard input and standard error are attached to a
 | terminal, the shell is considered to be interactive.
 |
 |So there's nothing in POSIX about login(1) tacking a leading hyphen on
 |and using that to trigger the shell to become a login shell.
 |
 |Indeed from what I can tell POSIX has nothing whatsoever to say about
 |"login shells" nor /etc/profile or $HOME/.profile.
 |
 |I guess to be entirely POSIX compatible my test should include:
 |
 | tty >/dev/null 2>&1 && tty <&1 >/dev/null 2>&1 &&
 |  [ "$0" = "$SHELL" ] &&
 |  _interactive=true


then you have to go Simon J. Gerraty who ensured me that he always
uses -t and i found out then this indeed is very old and usable.
-t 0 && -t 2, thus.
(I think Robert fixed the NetBSD shell to also go 0 and 2 lately.)

(And, dear Robert, i am not looking at the other emails as i am
afraid you have given an answer (and it surely says something like
that the space is a separator put by echo); i had a thinking
coming into my brain when i was doing the dishwash, last night.)

--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.