Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: read with redirected stdin

On Sun, Jan 8, 2023 at 3:22 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Roman Perepelitsa wrote on Sun, Jan 08, 2023 at 14:48:24 +0100:
> >
> > Doesn't $TTY already provide a better alternative?
> $TTY could be unset or set to another value without affecting the
> controlling terminal.

Paranoid scripts can do this:

    zsh -fc 'print -r -- $TTY'

However, if one is overriding TTY, then they perhaps want to affect
scripts that read it (similarly to overriding HOME or HOST). In any
case, scripts can decide whether to pick up $TTY that might have been
altered or use the paranoid construct from above.

> Anyway, I suppose I should revise my point to 'Can we determine at the C
> level whether we have a controlling terminal more reliably than by
> checking $TTY, and if so, should we expose that to scripts'.

Zsh already knows how to set TTY, so the answer to the first question
must be "yes".

For the second question it would be nice to have a use case that
cannot already be solved by $TTY.


Messages sorted by: Reverse Date, Date, Thread, Author