Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "does not contain a file descriptor" (Re: cat as a builtin command)
- X-seq: zsh-workers 33090
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: "does not contain a file descriptor" (Re: cat as a builtin command)
- Date: Tue, 02 Sep 2014 09:43:11 +0100
- In-reply-to: <140901124403.ZM14354@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <BLU436-SMTP2045383EF41756D3376DB3CF4DB0@phx.gbl> <20140901075315.GA5908@localhost.localdomain> <140901113940.ZM2031@torch.brasslantern.com> <140901124403.ZM14354@torch.brasslantern.com>
On Mon, 01 Sep 2014 12:44:03 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sep 1, 11:39am, Bart Schaefer wrote:
> }
> } torch% exec {fd}<&-
> } zsh: parameter fd does not contain a file descriptor
> }
> } It appears that only an UNSET parameter name triggers the "does not
> } contain" error; a set-but-empty parameter is treated as 0 and closes
> } standard input
>
> Do we really want that behavior?
No, that doesn't seem a good idea.
> Or the following behavior?
>
> torch% declare fd="12+7"
> torch% exec {fd}<&-
> zsh: failed to close file descriptor 19: bad file descriptor
>
> Patch below makes this somewhat more rigorous; but if the parameter is
> declared as an integer, then even its string value is zero when no value
> has been assigned, so the original problem can't be completely avoided.
> (As far as I can tell, perhaps I'm wrong?)
The default value for an integer is 0, unless you explicitly set it.
There's no separate string default --- the string value comes from
converting the integer value each time it's needed. So I think this is
unavoidable. We could advise users to initialise fd variables to -1.
> I won't commit this without getting feedback, because it doesn't work
> correctly with parameters declared as integers in bases other than 10
> (also 8 if you set OCTAL_ZEROS, and also 16 if you set C_BASES). So
> other suggestions are welcome ... or we can just document that all file
> descriptors must be base-10 integers, in which case we should change the
> base from 0 to 10 in the zstrtol() call.
I don't think this problem's fatal, but it's surprising if there isn't
some way or other of getting this to work by indicating the base
appropriately.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author