From 5d71d12ed2c19dd295a077127e5736c7718cbab3 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 8 Feb 2010 10:24:38 +0000 Subject: 27658: work around globbing problems in zip completion --- Completion/Unix/Command/_zip | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Completion/Unix/Command/_zip b/Completion/Unix/Command/_zip index 26e19a119..a6baa9757 100644 --- a/Completion/Unix/Command/_zip +++ b/Completion/Unix/Command/_zip @@ -1,6 +1,6 @@ #compdef zip unzip zipinfo -local suffixes suf zipfile uzi +local suffixes suf zipfile uzi testfile local expl curcontext="$curcontext" state line ret=1 typeset -A opt_args @@ -114,10 +114,18 @@ case $state in if [[ $service = zip ]] && (( ! ${+opt_args[-d]} )); then _wanted files expl zfile _files -g '^(#i)*.(zip|xpi|[ejw]ar)(-.)' && return else - zipfile=( $~line[1](|.zip|.ZIP) ) - [[ -z $zipfile[1] ]] && return 1 - if [[ $zipfile[1] != $_zip_cache_list ]]; then - _zip_cache_name="$zipfile[1]" + testfile=${~${(Q)line[1]}} + if [[ -f $testfile ]]; then + zipfile=$testfile + elif [[ -f $testfile.zip ]]; then + zipfile=$testfile.zip + elif [[ -f $testfile.ZIP ]]; then + zipfile=$testfile.ZIP + else + return 1 + fi + if [[ $zipfile != $_zip_cache_name ]]; then + _zip_cache_name="$zipfile" _zip_cache_list=( ${(f)"$(zipinfo -1 $_zip_cache_name)"} ) fi _wanted files expl 'file from archive' \ -- cgit 1.4.1