Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: cat as a builtin command
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author