zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _file_descriptors: initialize `list' array with local -a
@ 2015-06-16  5:31 Eric Cook
  2015-06-16  7:42 ` Oliver Kiddle
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Cook @ 2015-06-16  5:31 UTC (permalink / raw)
  To: zsh-workers

I noticed the descriptions _file_descriptors offers doesn't match what is currently presented
(only tried linux) _foo() _file_descriptors; compdef _foo foo

It happens when `list' is converted from a scalar to an array using list+=(...)
an empty string is the first element, so the two arrays `list' and `fd' aren't the same length 
when compadd is used.

I also silence stderr for the loops of fds since another error happens when used:
_file_descriptors:zstat:12: /proc/18123/fd/3: no such file or directory


 Completion/Zsh/Type/_file_descriptors | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Completion/Zsh/Type/_file_descriptors b/Completion/Zsh/Type/_file_descriptors
index 3e251b7..438fcc8 100644
--- a/Completion/Zsh/Type/_file_descriptors
+++ b/Completion/Zsh/Type/_file_descriptors
@@ -1,6 +1,7 @@
 #autoload
 
-local i fds expl list link sep
+local i fds expl link sep
+local -a list
 
 fds=( /dev/fd/<0-9>(N:t) )
 
@@ -20,7 +21,7 @@ if zstyle -T ":completion:${curcontext}:" verbose && [[ -h /proc/$$/fd/$fds[1] ]
     for i in "${fds[@]}"; do
       list+=( "$i $sep $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
     done
-  fi
+  fi 2>/dev/null
 
   if (( $list[(I)* $sep ?*] )); then
     _wanted file-descriptors expl 'file descriptor' compadd "$@" -d list -a - fds
-- 
2.4.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-06-23  1:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-16  5:31 [PATCH] _file_descriptors: initialize `list' array with local -a Eric Cook
2015-06-16  7:42 ` Oliver Kiddle
2015-06-16 15:58   ` Eric Cook
2015-06-17 14:57     ` Oliver Kiddle
2015-06-18 21:33       ` Oliver Kiddle
2015-06-19 13:01         ` Danek Duvall
2015-06-23  1:19           ` Oliver Kiddle

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).