Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Testing if a file is a terminal?
- X-seq: zsh-users 13557
- From: Peter Stephenson <pws@xxxxxxx>
- To: "Zsh users list" <zsh-users@xxxxxxxxxx>
- Subject: Re: Testing if a file is a terminal?
- Date: Tue, 9 Dec 2008 17:00:01 +0000
- In-reply-to: <6cd6de210812090847i1d0d76b8wf107e5c8ea2f0f9e@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
- References: <6cd6de210812090847i1d0d76b8wf107e5c8ea2f0f9e@xxxxxxxxxxxxxx>
On Tue, 9 Dec 2008 11:47:51 -0500
"Rocky Bernstein" <rocky.bernstein@xxxxxxxxx> wrote:
> First, many thanks to Peter and StÃphane for the very informative
> answers on terminal redirection.
>
> Before allowing a terminal to be set, the zshdb debugger uses this test:
>
> [[ -r "$1" && -w "$1" ]] && return 0 # Ok
>
> $1 is a string -- the device name (e.g. /dev/pts/1) -- not a file descriptor.
>
> But is this really the best one can do?
(Let's see if StÃphane beats me.)
[[ -t 0 ]] < $1
appears to do the right thing. Obviously it fails if the file can't be
read, too, but that's surely OK.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author