From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2733 invoked by alias); 18 Jun 2015 21:40:32 -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: 35521 Received: (qmail 21372 invoked from network); 18 Jun 2015 21:40:29 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1434663223; bh=N8At7hetzGCrr5Y0HVUWGkAzIfDZ+5DIvqZ4ZUWUpsQ=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=kzuxolfPflA0i5JTHtTGqWlC+yn/rmhxWguBuykyZfknyQtLvBqEU2a1yqhAQbFC6EpgkWL597qKsOOTm+iIQ9lALI6u1VHGpDhXBWX72o88bgXS4LMO4KcOb4YJN8Fb4IzhqV+H3/7OvyxFYONDJC/uPzXY5aFxEh0QLr/ra8fPvYhPDfFWjLBh4X6b99nhlZMRKXMpAFBf1FUsfD16GPrsjEqXbJ+CiblEetducZc4cAHPrLiop+5phbKB3K2foIZDcplf+/4ovAliFwXqxiLTzdzX/8/QwJNHXuC/UQfDawXB7VnFaPnJMpsHnJN+bSYMKn2gGPG7gwXCabWcHQ== X-Yahoo-Newman-Id: 468567.68686.bm@smtp119.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 2t78gaUVM1mabZtpAsFAgrzuTPAEN2f9ycGs9gAMIs7NU2i EYHRD_cl.JNHVr7ZN0edNocDOFK4plTpDG0UhDGuqprXrQ58_h28C1BKp2ze 7rxa0hlPy4wGgkXeHjHEeFWtaElfbzVE_nqsBH9UQ219QGOYsxD8LVQ7M2YG yEmPla5kGlByo0UNy4Co_uI3FdAsQxWZdgevcoAvIA6viiM9f.y.JOhqfkRU mlxiLP5mPJ0ATliY8IQDufpDvvGLvr_wRHEchBj_thXRYY0GOkjYrYTHo4kx EtsmdEz4avNsLsHQ3y5kiuBaPlY7GMvFZ27ezooIGojoiL.meYMhssuE4e5C zt6E3OK4n3ppZOnxz9pSU0BTZj1qIx3TK5aTYxPSeyzwkdtisUVpJukoZr57 bXZJSuQdd0KRcm_BxqDFNsrbP2csgj3fkuDDOOc2fQXyBhm3VwlyP2_FRtfw i1rvg15qMMt2aUunV_kaQR4vYuuRvSbnCKXSn2A.s0i0QRE4WceqQhD4vA5g qb6.WPyUyeHDlDTIV2B4Qa8ZdIBXeNWQw X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <29394.1434553069@thecus.kiddle.eu> From: Oliver Kiddle References: <1434432668-18303-1-git-send-email-llua@gmx.com> <22433.1434440572@thecus.kiddle.eu> <558047B6.4090908@gmx.com> <29394.1434553069@thecus.kiddle.eu> To: zsh-workers@zsh.org Subject: Re: [PATCH] _file_descriptors: initialize `list' array with local -a MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2671.1434663222.1@thecus.kiddle.eu> Date: Thu, 18 Jun 2015 23:33:42 +0200 Message-ID: <2672.1434663222@thecus.kiddle.eu> I wrote: > The updated function looks good. One slight issue is that description > separators don't align now that two digit fds are included: I was going to commit this with that small tweak but noticed that it also needed to handle sorting manually so that e.g. 10 is placed after 3. Given a few further tweaks and the addition of pfiles use for Solaris it seems necessary to post a patch. Oliver diff --git a/Completion/Zsh/Type/_file_descriptors b/Completion/Zsh/Type/_file_descriptors index 0b2cd00..52fe4bf 100644 --- a/Completion/Zsh/Type/_file_descriptors +++ b/Completion/Zsh/Type/_file_descriptors @@ -1,16 +1,23 @@ #autoload -local i fds expl link sep +local i fds expl disp link sep local -a list fds=( /dev/fd/<3->(N:t) ) +fds=( ${(n)fds} ) -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 +if zstyle -T ":completion:${curcontext}:file-descriptors" verbose; then + zstyle -s ":completion:${curcontext}:file-descriptors" list-separator sep || sep=-- + if [[ $OSTYPE = solaris* ]]; then + fds=( ${${(f)"$(pfiles $$|nawk 'NR==1{next} /^ *[0-9]*:/ {printf "\n%s", $1} / *\// {print $1}')"}:#[012]:*} ) + zformat -a list " $sep " $fds + fds=( ${fds%%:*} ) + elif [[ ! -h /proc/$$/fd/$fds[1] ]]; then + : + elif zmodload -F zsh/stat b:zstat; then for i in "${fds[@]}"; do if zstat +link -A link /proc/$$/fd/$i; then - list+=( "$i $sep ${link[1]}" ) + list+=( "${(r.$#fds[-1].)i} $sep ${link[1]}" ) else fds[(i)$i]=() fi @@ -18,7 +25,7 @@ if zstyle -T ":completion:${curcontext}:" verbose && [[ -h /proc/$$/fd/$fds[1] ] elif (( $+commands[readlink] )); then for i in "${fds[@]}"; do if link=$(readlink /proc/$$/fd/$i); then - list+=( "$i $sep $link" ) + list+=( "${(r.$#fds[-1].)i} $sep $link" ) else fds[(i)$i]=() fi @@ -26,19 +33,23 @@ if zstyle -T ":completion:${curcontext}:" verbose && [[ -h /proc/$$/fd/$fds[1] ] else for i in "${fds[@]}"; do if link=$(ls -l /proc/$$/fd/$i); then - list+=( "$i $sep ${link#* -> }" ) + list+=( "${(r.$#fds[-1].)i} $sep ${link#* -> }" ) else fds[(i)$i]=() fi done 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 + if (( list[(I)* $sep ?*] )); then + list=( + "${(r.$#fds[-1].):-0} $sep standard input" + "${(r.$#fds[-1].):-1} $sep standard output" + "${(r.$#fds[-1].):-2} $sep standard error" $list + ) + disp=( -d list ) fi + fds=( 0 1 2 $fds ) fi -_wanted file-descriptors expl 'file descriptor' compadd -a "$@" - fds +_description -V file-descriptors expl 'file descriptor' +compadd $disp "${@/-J/-V}" "$expl[@]" -a fds