summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Cook <llua@gmx.com>2015-06-18 22:41:47 +0200
committerOliver Kiddle <opk@zsh.org>2015-06-18 22:41:47 +0200
commit2e1bb72c072193bbd5c32a32aaad2cb942656ee8 (patch)
treedbcf734cd170cf957f6d1cdab759bd793644bb7a
parente55c16708320aee327fe192d543a25e05343fae5 (diff)
downloadzsh-2e1bb72c072193bbd5c32a32aaad2cb942656ee8.tar.gz
zsh-2e1bb72c072193bbd5c32a32aaad2cb942656ee8.tar.xz
zsh-2e1bb72c072193bbd5c32a32aaad2cb942656ee8.zip
35490: silence errors and avoid blank match due to missing local
-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