zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@u.genie.co.uk>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: completion for file descriptors
Date: Thu, 20 Apr 2000 00:41:26 +0100	[thread overview]
Message-ID: <38FE4426.75E6DAD1@u.genie.co.uk> (raw)

Here is the completion for file descriptors which was discussed during
the day along with a few small changes to _print to use it and to handle
-p only when the is a coprocess. Can anyone see any problems or
alternatives to my fallback method of finding links of using ls -l piped
into sed? The stat module works well but I didn't want to use it if it
wasn't loaded because it isn't there by default. On IRIX, I seem to get
all 10 file descriptors listed regardless and I can't see a way round
it, not that it matters much. If put _file_descriptors in Core because
it will be used by _redirect and because other things like _options is
there - it can always be moved.

Oliver

Index: Completion/Builtins/_print
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_print,v
retrieving revision 1.1
diff -r1.1 _print
3c3
< local state expl line eflag
---
> local state expl line eflag pflag
7a8,11
> # -p flag only relevant if we have a coprocess
> (:>&p) 2>/dev/null &&
>   pflag='(-s -u -z)-p[print arguments to input of coprocess]'
> 
21,22c25
<   '(-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' \
26c29
<   $eflag '*:default:_default'
---
>   $pflag $eflag '*:default:_default'
Index: Completion/Core/_file_descriptors
===================================================================
RCS file: _file_descriptors
diff -N _file_descriptors
0a1,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


             reply	other threads:[~2000-04-20  0:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-19 23:41 Oliver Kiddle [this message]
2000-04-20  7:18 Sven Wischnowsky
2000-04-20  9:19 ` Oliver Kiddle
2000-04-20  9:31   ` Thomas Köhler
2000-04-20  9:54 Sven Wischnowsky
2000-04-20 10:58 ` Oliver Kiddle
2000-04-20 11:10 Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=38FE4426.75E6DAD1@u.genie.co.uk \
    --to=opk@u.genie.co.uk \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).