From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7402 invoked by alias); 16 Jun 2015 05:31:25 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35483 Received: (qmail 19309 invoked from network); 16 Jun 2015 05:31:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 From: Eric Cook To: zsh-workers@zsh.org Subject: [PATCH] _file_descriptors: initialize `list' array with local -a Date: Tue, 16 Jun 2015 01:31:08 -0400 Message-Id: <1434432668-18303-1-git-send-email-llua@gmx.com> X-Mailer: git-send-email 2.4.2 X-Provags-ID: V03:K0:auxqFVK4RCpo6A0SU7qjo4E3zJ49nzyOdu3qTN4AoqGDg0jewvT iECIpADNrm8vC/BSGo6b1wO69ez3DooPt3y78J5NJVEz34x4VlJS8h6cLPgnS/otybmNmX0 BqT1FkJuMXjvs/TUjsWVDFh3iT46vs+INm1kF0vyOa8QyB+2GYHaGA6dwTOOvV7vBj3/2CE xyumzTFLoTKQ5YZb+Q6Sg== X-UI-Out-Filterresults: notjunk:1; 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 @@ #autoload -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/.*-> //' )" ) done - fi + fi 2>/dev/null if (( $list[(I)* $sep ?*] )); then _wanted file-descriptors expl 'file descriptor' compadd "$@" -d list -a - fds -- 2.4.2