Re: interactive shell detection in shrc
"Greg A. Woods" <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.userlevel |
|---|---|
| Organization | Planix, Inc. |
| Message-ID | <[email protected]> |
At Fri, 27 Sep 2024 07:14:46 +0700, Robert Elz <[email protected]> wrote: Subject: Re: interactive shell detection in shrc > > Date: Thu, 26 Sep 2024 15:16:39 -0700 > From: "Greg A. Woods" <[email protected]> > Message-ID: <[email protected]> > > | I'm very curious: why did you include "m" in that test? > > I wondered about that as well. But I suspect you have > supplied the answer. > > | I do note the following from the bosh(1) manual: > | > | ... POSIX requires that job control is auto-enabled for > | interactive shells ... > > It actually requires it to be on by default in interactive shells, > that's almost what the above says, but it could be read as not > allowing "sh +m" to start an interactive shell with job control > disabled -- which is not what posix requires. > > | But I'm pretty sure the key word there is "interactive", which will by > | definition also mean they have 'i' in $-. > > It would, but as you point out -i isn't always available there, but -m > should be, But that was my point! "m" is not in $- either! However it seems my own test conflates the condition of being a "login shell" with being "interactive". 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 -- Greg A. Woods <[email protected]> Kelowna, BC +1 250 762-7675 RoboHack <[email protected]> Planix, Inc. <[email protected]> Avoncote Farms <[email protected]>
signature.asc
(application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRuK6dmwVAucmRxuh9mfXG3eL/0fwUCZvcaDgAKCRBmfXG3eL/0 fwRJAJ9ZL7LlXdY+1cIPeD2tCEi5vzzJHgCdEWEF9wFel51rLYqce01gFlC+yfk= =Xxjh -----END PGP SIGNATURE-----