Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Testing if a file is a terminal?
- X-seq: zsh-users 13593
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Testing if a file is a terminal?
- Date: Thu, 11 Dec 2008 13:32:03 -0500
- Cc: "Zsh users list" <zsh-users@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=L3TlGhAaTaQLIOb3QuYuEkV0F8fIYIRM8/Sc4fKZH7g=; b=j+uCC1YyDwQGA0xvuVdJFiVAJZiLNkLKtH0GWvhTSKFpaWoDEmjOBieH3mgCFZNogD zKzEWEvCgq3R2dExD3YOYscSsbbDnswD9Hlvc4dNT9jUl6d8AdXb6A99SYpqpcJ7+18O EaIosS6LOG73EM3ytD2kKKZGMRwMk05tlKeiE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=bAx2vU8j2HBFDoPayzXX0JHy2MTJjfjT5u/MObzuiuCbQ+OZqGlsZDSzGC+zp6I7Om qxaHbJnd37ATSV8u77w8EfXZWov496oEtnFTgj13kgm4qMSc2hrRoe/5pHb69+ZzH75X 613Q/rJBS9FMjWVZkLGRVhj+wYtSdMF2raAs4=
- In-reply-to: <081211101721.ZM21796@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <6cd6de210812090847i1d0d76b8wf107e5c8ea2f0f9e@xxxxxxxxxxxxxx> <6cd6de210812110933i533eb92ei7f603673af235fa5@xxxxxxxxxxxxxx> <081211101721.ZM21796@xxxxxxxxxxxxxxxxxxxxxx>
On Thu, Dec 11, 2008 at 1:17 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Dec 11, 12:33pm, Rocky Bernstein wrote:
> } Subject: Re: Testing if a file is a terminal?
> }
> } David Korn has weighed in on this with respect to ksh.
> }
> } Here is code along he lines he has suggested (my formatting and other
> } small changes which may have introduced bugs):
>
> This is almost exactly what I suggested,
Then without a doubt you are on par with David Korn ;-)
> except I omitted the
>
> exec {fd}<&-
>
> because you expressed concern about opening and then closing again
> the terminal device.
Yes, that was the original problem. I can and may rewrite the function
to be open_if_tty rather than is_tty.
> In fact, I might even suggest:
>
> if [[ -t $fd ]] ; then
> r=0
> else
> exec {fd}<&-
> fi
>
Good suggestion. If I rewrite is_tty as open_if_tty will probably use. Thanks.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author