At Fri, 27 Sep 2024 01:32:34 +0200, Steffen Nurpmeso <steffen%sdaoden.eu@localhost> wrote:
Subject: Re: interactive shell detection in shrc
>
> Hello.
>
> Greg A. Woods wrote in <m1stwmt-0036s2C@more.local>:
> |At Tue, 24 Sep 2024 00:56:40 +0200, Steffen Nurpmeso <steffen%sdaoden.eu@localhost> \
> |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 <gwoods%acm.org@localhost>
Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
Attachment:
pgp3bSNUURYF7.pgp
Description: OpenPGP Digital Signature