tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: interactive shell detection in shrc
Steffen Nurpmeso wrote in
<20240927224352.XbfXbbOA@steffen%sdaoden.eu>:
|Robert Elz wrote in
| <10279.1727476502%jacaranda.noi.kre.to@localhost>:
| ...
||| 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 <kre%NetBSD.org@localhost>
AuthorDate: 2017-07-24 12:35:37 +0000
Commit: kre <kre%NetBSD.org@localhost>
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)
Home |
Main Index |
Thread Index |
Old Index