Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why do I get a "bad filedescriptor" here? (redirection problem)
- X-seq: zsh-users 10901
- From: Phil Pennock <phil.pennock@xxxxxxxxxxx>
- To: Com MN PG P E B Consultant 3 <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx>
- Subject: Re: Why do I get a "bad filedescriptor" here? (redirection problem)
- Date: Wed, 25 Oct 2006 12:55:41 +0200
- Cc: zsh-users Mailinglist <zsh-users@xxxxxxxxxx>
- In-reply-to: <F7507090F1A72B43A51444325DFBE43101426B12@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Com MN PG P E B Consultant 3 <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx>, zsh-users Mailinglist <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <F7507090F1A72B43A51444325DFBE43101426B12@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: Phil Pennock <phil@xxxxxxxxxxxxx>
On 2006-10-25 at 10:52 +0200, Com MN PG P E B Consultant 3 wrote:
> zsh 4.0.7
>
> $ ls >& -
> /bin/ls: write error: Bad file descriptor
> $ cat >&- <<<d
> cat: standard output: Bad file descriptor
> $ ls >/dev/null
> $ echo x >& -
> $
>
> Why do I get a "bad file descriptor" in the first two cases?
Because you've closed it, so it's not available for writing. Most tools
just assume that file descriptors 0, 1 and 2 are available for use and
will just write to stdout without checking, so they'll get errors and
complain like that when it's closed.
> Note that closing stdout with echo works fine, as does
> (of course) redirection of ls output to the bit bucket.
echo as a shell built-in is handling it gracefully, because zsh is
handling what you meant, not what you wrote. Try it with /bin/echo and
you'll see it fail in the same way as the other commands.
If you want to discard output, redirect it to the bitbucket.
Regards,
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author