Re: interactive shell detection in shrc

[email protected]
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
On Fri, Oct 04, 2024 at 07:53:59AM -0700, George Georgalis wrote:
> On Mon, Sep 30, 2024 at 1:26?PM George Georgalis <[email protected]> wrote:
> 
> >
> > On Mon, Sep 30, 2024 at 1:09?PM <[email protected]> wrote:
> >
> >> So how can the test be reliable in all circumstances?
> >>
> >
> > test -t 0
> >
> > is reliable.
> >
> > I use
> >
> > tty -s || return 0
> >
> > to remind me what I'm testing for (same difference),
> > and branch out of .profile for not interactive sessions.
> >
> 
> Is there a case where this is not the solution?
> When I decided this is what interactive means
> all of the edge cases went away. Is there a
> case I am not considering?

None that I'm aware of. I---as many others I think---didn't even know that
test(1) has an option to test this. It seems it's the more reliable as
long as the systems on which the script has to be interpreted as a
test(1)---or a builtin of that name---that understands the option.

-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C
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.