summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2000-04-20 00:48:27 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2000-04-20 00:48:27 +0000
commita903dcba4f0c0ae7b0b80d60604c8a30825aa4e1 (patch)
tree58fa0c22e0ee085a254e15fd41c8b2b3c360ab32
parentcd962793dfcc547b5c0933c4c8bcce1b1e859a7b (diff)
downloadzsh-a903dcba4f0c0ae7b0b80d60604c8a30825aa4e1.tar.gz
zsh-a903dcba4f0c0ae7b0b80d60604c8a30825aa4e1.tar.xz
zsh-a903dcba4f0c0ae7b0b80d60604c8a30825aa4e1.zip
Add completion for file descriptors
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Builtins/_print11
-rw-r--r--Completion/Core/.distfiles4
-rw-r--r--Completion/Core/_file_descriptors23
4 files changed, 38 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index cc5471595..95067ff07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2000-04-20  Oliver Kiddle  <opk@zsh.org>
+
+	* 10848: Completion/Builtins/_print, Completion/Core/.distfiles,
+	Completion/Core/_file_descriptors: Add completion for file
+	descriptors
+
 2000-04-19  Peter Stephenson  <pws@pwstephenson.fsnet.co.uk>
 
 	* Config/version.mk: 3.1.7-pre-1
diff --git a/Completion/Builtins/_print b/Completion/Builtins/_print
index f2634e124..11b089a14 100644
--- a/Completion/Builtins/_print
+++ b/Completion/Builtins/_print
@@ -1,10 +1,14 @@
 #compdef print
 
-local state expl line eflag
+local state expl line eflag pflag
 
 # -e flag available only after -R 
 eflag="${words[1,CURRENT-1][(r)-*R*]:+-e[enable escapes]}"
 
+# -p flag only relevant if we have a coprocess
+(:>&p) 2>/dev/null &&
+  pflag='(-s -u -z)-p[print arguments to input of coprocess]'
+
 _arguments -C -s \
   '-r[ignore escape conventions of echo]' \
   '(-r -b -m -s -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \
@@ -18,9 +22,8 @@ _arguments -C -s \
   '(-o)-O[sort arguments in descending order]' \
   '-i[case-insensitive sorting]' \
   '(-n -l -N)-c[print arguments in columns]' \
-  '(-s -p -z)-u+[specify file-descriptor to print arguments to]:file-descritor' \
-  '(-s -u -z)-p[print arguments to input of coprocess]' \
+  '(-s -p -z)-u+[specify file-descriptor to print arguments to]:file-descriptor:_file_descriptors' \
   '(-s -p -u)-z[push arguments onto editing buffer stack]' \
   '-D[substitute any arguments which are named directories using ~ notation]' \
   '-P[perform prompt expansion]' \
-  $eflag '*:default:_default'
+  $pflag $eflag '*:default:_default'
diff --git a/Completion/Core/.distfiles b/Completion/Core/.distfiles
index ff67b283e..9ddf7f523 100644
--- a/Completion/Core/.distfiles
+++ b/Completion/Core/.distfiles
@@ -1,8 +1,8 @@
 DISTFILES_SRC='
     .distfiles
     _all_labels _alternative _approximate
-    _call _compalso _complete _correct _description
-    _expand _files _funcall _ignored _list _main_complete _match
+    _call _compalso _complete _correct _description _expand
+    _file_descriptors _files _funcall _ignored _list _main_complete _match
     _menu _multi_parts _message _next_label _normal _oldlist _options
     _parameters _path_files _prefix _requested _sep_parts
     _set_options _setup _sort_tags _tags
diff --git a/Completion/Core/_file_descriptors b/Completion/Core/_file_descriptors
new file mode 100644
index 000000000..37e44c068
--- /dev/null
+++ b/Completion/Core/_file_descriptors
@@ -0,0 +1,23 @@
+#autoload
+
+local i fds expl list link
+
+for i in {0..9}; [[ -e /dev/fd/$i ]] && fds=( ${fds[@]} $i )
+
+if zstyle -T ":completion:${curcontext}" verbose && [[ -e /proc/$$/fd ]]; then
+  if zmodload -e zsh/stat; then
+    for i in "${fds[@]}"; do
+      stat +link -A link /proc/$$/fd/$i
+      list=( ${list[@]} "$i -- ${link[1]}" )
+    done
+  elif (( $+commands[readlink] )); then
+    for i in "${fds[@]}"; list=( ${list[@]} "$i -- $(readlink /proc/$$/fd/$i)" )
+  else
+    for i in "${fds[@]}"; do
+      list=( ${list[@]} "$i -- $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
+    done
+  fi
+  _wanted file-descriptors expl 'file descriptors' compadd "$@" -d list - "$fds[@]"  
+else
+  _wanted file-descriptors expl 'file descriptors' compadd "$@" - "$fds[@]"
+fi