summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Zsh/Type/_file_descriptors29
2 files changed, 27 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a11c3669..f76eae223 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-18  Oliver Kiddle  <opk@zsh.org>
+
+	* Eric Cook: 35490: Completion/Zsh/Type/_file_descriptors:
+	silence errors and avoid blank match due to missing local
+
 2015-06-17  Mikael Magnusson  <mikachu@gmail.com>
 
 	* 35477: Completion/Unix/Command/_gdb: _gdb: Allow 'core' to
@@ -34,7 +39,7 @@
 	* 35442: Doc/Zsh/options.yo: multibyte option now on
 	everywhere by default.
 
-2015-06-08  Oliver Kiddle  <opk@zsh.org>
+2015-06-09  Oliver Kiddle  <opk@zsh.org>
 
 	* 35418: Doc/Zsh/compsys.yo: fix usage synopsis for _describe
 	to be clear that a single description is used
diff --git a/Completion/Zsh/Type/_file_descriptors b/Completion/Zsh/Type/_file_descriptors
index 3e251b733..0b2cd0015 100644
--- a/Completion/Zsh/Type/_file_descriptors
+++ b/Completion/Zsh/Type/_file_descriptors
@@ -1,28 +1,41 @@
 #autoload
 
-local i fds expl list link sep
+local i fds expl link sep
+local -a list
 
-fds=( /dev/fd/<0-9>(N:t) )
+fds=( /dev/fd/<3->(N:t) )
 
 if zstyle -T ":completion:${curcontext}:" verbose && [[ -h /proc/$$/fd/$fds[1] ]]; then
   zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
-
   if zmodload -F zsh/stat b:zstat; then
     for i in "${fds[@]}"; do
-      zstat +link -A link /proc/$$/fd/$i
-      list+=( "$i $sep ${link[1]}" )
+      if zstat +link -A link /proc/$$/fd/$i; then
+        list+=( "$i $sep ${link[1]}" )
+      else
+        fds[(i)$i]=()
+      fi
     done
   elif (( $+commands[readlink] )); then
     for i in "${fds[@]}"; do
-      list+=( "$i $sep $(readlink /proc/$$/fd/$i)" )
+      if link=$(readlink /proc/$$/fd/$i); then
+        list+=( "$i $sep $link" )
+      else
+        fds[(i)$i]=()
+      fi
     done
   else
     for i in "${fds[@]}"; do
-      list+=( "$i $sep $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
+      if link=$(ls -l /proc/$$/fd/$i); then
+        list+=( "$i $sep ${link#* -> }" )
+      else
+        fds[(i)$i]=()
+      fi
     done
-  fi
+  fi 2>/dev/null
 
   if (( $list[(I)* $sep ?*] )); then
+    list=( "0 $sep standard input" "1 $sep standard output" "2 $sep standard error" $list )
+    fds=( 0 1 2 $fds )
     _wanted file-descriptors expl 'file descriptor' compadd "$@" -d list -a - fds
     return
   fi