bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unexpected output


From: Stephane Chazelas
Subject: Re: Unexpected output
Date: 04 Oct 2001 13:57:22 GMT
User-agent: slrn/0.9.7.0 (SunOS)

On Thu, 4 Oct 2001 15:20:28 +0200, Erik Braun <erik@minet.uni-jena.de> wrote:
> Description:
>         The command
>         $ finger -m $USER|grep $(tty | sed "s/^\/dev\///")
>         which outputs something like "on pts/8 from paxp22.mipool.uni-jena.de"
>         (using Bash 2.01) now prints strange errors:
>         
>         grep: can't open a
>         grep: can't open tty
>         
>         Strange enough, the distinct parts of the commands do what they
>         should do:
>         
>         $ echo $(tty | sed "s/^\/dev\///")
>         pts/8
>         $ finger -m $USER|grep pts/8
[...]

I guess, the "tty" command uses it's fd 0 to find the name of the
terminal. In the first case fd 0 is the same as grep's one (ie a
pipe).

I guess

: | tty

gives something like: "not a tty"

You should use:
TTY=$(tty)
finger -m $USER|grep "${TTY#/dev/}"

or

{ finger -m $USER| grep $(tty <&3 | sed 's,^/dev/,,'); } 3<&0


-- 
Stéphane



reply via email to

[Prev in Thread] Current Thread [Next in Thread]