Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Fix _file_descriptors
- X-seq: zsh-workers 30275
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: PATCH: Fix _file_descriptors
- Date: Mon, 27 Feb 2012 16:08:52 +0000 (GMT)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1330358932; bh=lf+gbtCsjLyS+GSxJwgxvjprOGyDDRo+rPvPzP3xPxY=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=e4JyqzEoGZ4NWOOZkTXrudvOfYRyOb+QnX3hscOhhfAsUdPSf86aY2rI7GEWqvOvOK63r2+aS0i6ABDEh3SnXPbtXx00eaFnwlvUY+aXhyQRBLb2MezH8kWAAOkpivQWYbKjGAhcCIhluwmtGRucg7eFz5I5iK4GTgslm9DUAR0=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=eNJThyiqKdEsOl57RN37GnsXgejsvWPMgZ3+8+JOjEBEkcOvlqwcN/5BcVtMKOsU5ujpick12x2rcS0pIqPsJbz9okCQHnCCbmp5QW11CLaLwsd0CL8UKyLM6FLKue+YZslZ6NT74a8ZjgQkGPZztQV3OF/gq6HhsTx95uEaKYw=;
- In-reply-to: <1330281433-23949-1-git-send-email-mikachu@gmail.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
--- On Sun, 26/2/12, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> I noticed file descriptor completion
> didn't work, with the verbose style set
> because when this is run,
> fds=( /dev/fd/<0-9>(N:t) )
> the /dev/fd dir is open while the glob is performed, which
> results in
> a spurious entry in the result, which then cannot be
> dereferenced. The
> result is that the list array is not aligned to the fds
> array (and also
> an error message is output), and an fd that doesn't exist is
> completed.
I'm not sure what you mean by "cannot be dereferenced".
In any case, this whole function can be simplified by using the newish :A modifier. Also, I'm fairly certain that it is intentional that this function only completes file descriptors from 0 - 9.
With :A, assigning fds can just be:
fds=( /dev/fd/<0-9>(e,'[[ $REPLY:A != /proc/$$/fd ]]',) )
It's probably best to build up list then with a for loop after checking the style but again :A can be used instead of trying the three old mechanisms.
Another approach would be to use a subshell to open the directory:
fds=( $(print /proc/$$/fd/<0-9>(N:t)) )
But I think there are some platforms that have /dev/fd but not /proc/$$/fd.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author