On Wed, 9 Mar 2011, Anton Zinoviev wrote:
On Wed, Mar 09, 2011 at 06:31:38PM +0100, Edward Tomasz Napierała wrote:
Not sure about the Debian userland, but the standard FreeBSD way
would be to use tty(1):
$ tty
/dev/ttyv0
Ah, thanks.
Does it make sence to use
tty <&2
This is saying "read from the place file descriptor 2 points to". fd 2
is, by convention, stderr (though this can be arranged to be not the case
in any number of ways); stderr is nominally an output channel. So,
reading from it does not really "make sense".
However, as you note, it usually works, because empirically the terminal
is opened read/write and dup'd to fds 1 and 2; with this knowledge, that
your expression works does "make sense".
-Ben Kaduk
if the standard input is redirected no longer from tty? Yes, it is
strange to use stderr as input but this seems to work on Debian with
Linux:
$ tty <&2
/dev/tty1
$ (tty <&2) </dev/zero
/dev/tty1
$ (tty ) </dev/zero
not a tty