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 01:32:34 +0200, Steffen Nurpmeso <[email protected]> wrote: Subject: Re: interactive shell detection in shrc > > Hello. > > Greg A. Woods wrote in <[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? > > Pfffffh .. likely because i wanted to use aliases under some > conditions? Unforunately history ends in 2015, where i resorted > my entire configuration, and moved it all to git, i think. > (There is home.attic in the first commit, with .cvsrc and .hgrc.) > This could be the answer, as this file includes things as here > > [ -f "${HOME}/.${OSTYPE}.alias" ] && . "${HOME}/.${OSTYPE}.alias" Perhaps I'm obtuse, but I think your answer is for some other question. What do aliases have to do with job control? > |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 > > This looks very much interesting, except that i would insist on > being afraid on that "if EXPANSION" thing. Huh? The use of the "if $var; then" construct has been rock-solid reliable in every shell I've ever seen since the 1980s. My SCCS history for my ~/.profile confirms I was using this construct well before 1993 so it definitely worked with the old System V Release 2 shell. See the whole history here: https://github.com/robohack/dotfiles.git Indeed I still test it regularly today with all the shells I encounter. Even zsh complies (and that's the shell I have the most problems with). -- 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/0fwUCZvb9YgAKCRBmfXG3eL/0 f6h/AJ94NeJf7Ws8Wrj/fmY4hCI6UvIhWgCgkt+QWiIGIBYu9K2mwZ+Kyr99uj8= =pDcy -----END PGP SIGNATURE-----