zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org
Subject: Re: PATCH: Fix _file_descriptors
Date: Mon, 27 Feb 2012 16:08:52 +0000 (GMT)	[thread overview]
Message-ID: <1330358932.36076.YahooMailClassic@web29706.mail.ird.yahoo.com> (raw)
In-Reply-To: <1330281433-23949-1-git-send-email-mikachu@gmail.com>

--- On Sun, 26/2/12, Mikael Magnusson <mikachu@gmail.com> 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


  reply	other threads:[~2012-02-27 16:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-26 18:37 Mikael Magnusson
2012-02-27 16:08 ` Oliver Kiddle [this message]
2012-02-27 16:36   ` Mikael Magnusson

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=1330358932.36076.YahooMailClassic@web29706.mail.ird.yahoo.com \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@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).