On Tue, 23 Sep 2025 05:07:18 +0200 (CEST), Pourko wrote:
> On Thu, 18 Sep 2025 15:26:16 -0400 Chet Ramey wrote:
> > There isn't a good way for a shell script to determine whether or not
> > it's in the foreground or background, and whether it is in the same
> > process group as the terminal.
>
> Attached is the patch that does it.
> [...]
> -s FILE True if file exists and is not empty.
> -S FILE True if file is a socket.
> -t FD True if FD is opened on a terminal.
> + -T FD True if FD is opened on a terminal and is readable.
> -u FILE True if the file is set-user-id.
> -w FILE True if the file is writable by you.
> -x FILE True if the file is executable by you.
> [...]
>
> Now...
> [ -t 0 ] && [ ! -T 0 ]
> ...means we are running in the background.
It puzzles me that I seem to be the only one excited by this.
Don't you find it to be a useful thing to have?