Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] _file_descriptors: initialize `list' array with local -a

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 @@
-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/.*-> //' )" )
-  fi
+  fi 2>/dev/null
   if (( $list[(I)* $sep ?*] )); then
     _wanted file-descriptors expl 'file descriptor' compadd "$@" -d list -a - fds

Messages sorted by: Reverse Date, Date, Thread, Author