zsh-users
 help / color / mirror / code / Atom feed
From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: zsh-users@zsh.org
Subject: Re: cat as a builtin command
Date: Tue, 2 Sep 2014 09:08:35 +0800	[thread overview]
Message-ID: <20140902010835.GA2862@localhost.localdomain> (raw)
In-Reply-To: <140901113940.ZM2031@torch.brasslantern.com>

On Mon, Sep 01, 2014 at 11:39:40AM -0700, Bart Schaefer wrote:
> On Sep 1,  3:53pm, Han Pingtian wrote:
> }
> } It should be 
> } 
> }     exec {file}<&0
> } 
> } right? But I get error mesage for it:
> } 
> }     localhost% (){
> }     function> local fd
> }     function> exec {fd}<&0
> }     function> read -E -u $fd
> }     function> exec {fd}<&-
> }     function> }
> }     (anon):2: 0: bad file descriptor
> }     (anon):read:3: argument expected: -u
> }     (anon):4: failed to close file descriptor 0: bad file descriptor
> 
> I'm not able to reproduce this.  Is this in a newly started shell?
> 
>     torch% (){           
>     local fd  
>     function> exec {fd}<&0
>     function> read -E -u $fd
>     function> exec {fd}<&-
>     function> }
>     hello
>     hello
>     torch% 
> 
> I *suspect* that what happened is that while you were experimenting, some
> previous "exec <&-" has already closed descriptor 0.  Closing stdin is
> not fatal to an interactive zsh, it maintains its own descriptor for ZLE
> to access /dev/tty.
> 
> E.g., if I explicitly do:
> 
> torch% exec 0<&-   
> 
> Then up-history a couple of times and:
> 
> torch% (){         
> local fd
> exec {fd}<&0
> read -E -u $fd
> exec {fd}<&-
> }
> (anon):2: 0: bad file descriptor
> (anon):read:3: argument expected: -u
> (anon):4: failed to close file descriptor 0: bad file descriptor
> torch% 
Thanks, I cannot reproduce it after a reboot now. I think you are right,
I must closed 0 before the test. Thanks so much.


      reply	other threads:[~2014-09-02  1:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-29  1:40 Izumi Natsuka
2014-08-29 11:58 ` Roman Neuhauser
2014-08-29 12:24 ` Dirk Heinrichs
2014-08-29 13:20   ` Roman Neuhauser
2014-08-29 13:33     ` Dirk Heinrichs
2014-08-29 13:03 ` Peter Stephenson
2014-08-30 10:11   ` Mikael Magnusson
2014-09-01  7:53 ` Han Pingtian
2014-09-01 18:39   ` Bart Schaefer
2014-09-02  1:08     ` Han Pingtian [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140902010835.GA2862@localhost.localdomain \
    --to=hanpt@linux.vnet.ibm.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).