Re: interactive shell detection in shrc

Steffen Nurpmeso <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <20240927232234.qy0ewIN3@steffen%sdaoden.eu>
Steffen Nurpmeso wrote in
 <20240927224352.XbfXbbOA@steffen%sdaoden.eu>:
 |Robert Elz wrote in
 | <[email protected]>:
 | ...
 ||| I guess to be entirely POSIX compatible my test should include:
 |||
 |||  tty >/dev/null 2>&1 && tty <&1 >/dev/null 2>&1 &&
 ||
 ||The second of those would need to be testing (the pre-redirected)
 ||stderr, not stdout, interactive shells don't care where stdout has
 ||been sent (though the user probably does).
 ||
 ||But as Steffen (kind of) indicated, "test -t 0 && test -t 2" is
 ||probably an easier way than using tty.

I must apologise, that "recently" was in 2017, over seven years
ago!  (But dash will change no sooner but with the next release,
i think .. actually not in git as of 2024-07-28.  Will ask..)

  commit a373e69a196cd8d45f2806d805e548fa65a982ba
  Author:     kre <[email protected]>
  AuthorDate: 2017-07-24 12:35:37 +0000
  Commit:     kre <[email protected]>
  CommitDate: 2017-07-24 12:35:37 +0000

      PR standards/52406

      Absent other information, the shell should be interactive if reading
      from stdin, and stdin and stderr are ttys, not stdin and stdout.

      So sayeth the great lord posix.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
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.