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 Tue, 24 Sep 2024 00:56:40 +0200, Steffen Nurpmeso <[email protected]> wrote: Subject: Re: interactive shell detection in shrc > > case ${-} in > *i*|*m*) # {{{ > ... > esac I'm very curious: why did you include "m" in that test? I do note the following from the bosh(1) manual: ... POSIX requires that job control is auto-enabled for interactive shells ... But I'm pretty sure the key word there is "interactive", which will by definition also mean they have 'i' in $-. For what it's worth I the original Bourne shell (as supplied in pkgsrc shells/heirloom-sh) does not put 'i' in $- (ever). The enhanced Bourne shells, aka the Schily Bourne Shells, shells/bosh and shells/pbosh, similarly do not have 'i' in $- while sourcing ~/.profile, but they do adjust $- after ~/.profile has been sourced. Since they all derive from the same parent I guess the fact they share this quality should not be too surprising. 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 -- 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/0fwUCZvXdOwAKCRBmfXG3eL/0 fzGIAJ98uEKDQXeZqhpda46BK6hBHTIZDQCgouA75/Y7uaITpcZ75kvSFdt84xk= =0uu0 -----END PGP SIGNATURE-----