From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18227 invoked from network); 26 Feb 2003 13:11:08 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 26 Feb 2003 13:11:08 -0000 Received: (qmail 9039 invoked by alias); 26 Feb 2003 13:11:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18300 Received: (qmail 9021 invoked from network); 26 Feb 2003 13:11:00 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 26 Feb 2003 13:11:00 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [193.109.254.147] by sunsite.dk (MessageWall 1.0.8) with SMTP; 26 Feb 2003 13:10:58 -0000 X-VirusChecked: Checked X-Env-Sender: kiddleo@logica.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1046265057!2563 Received: (qmail 28999 invoked from network); 26 Feb 2003 13:10:57 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-4.tower-27.messagelabs.com with SMTP; 26 Feb 2003 13:10:57 -0000 Received: from finches.logica.co.uk ([158.234.142.11]) by iris.logica.co.uk (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id NAA31966 for ; Wed, 26 Feb 2003 13:10:56 GMT X-Authentication-Warning: iris.logica.co.uk: Host [158.234.142.11] claimed to be finches.logica.co.uk Received: from finches.logica.co.uk (localhost [127.0.0.1]) by finches.logica.co.uk (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id h1QDEbD02057 for ; Wed, 26 Feb 2003 14:14:37 +0100 From: Oliver Kiddle To: Zsh workers Subject: PATCH: tar -C completion Date: Wed, 26 Feb 2003 14:14:37 +0100 Message-ID: <2055.1046265277@finches.logica.co.uk> Sender: kiddleo@logica.com This is a patch I've had around for a while. It improves tar completion when the -C option is used but there is still plenty of room for further improvement. I've been meaning to fix _tar more properly but haven't got around to it. Oliver Index: Completion/Unix/Command/_tar =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_tar,v retrieving revision 1.1 diff -u -r1.1 _tar --- Completion/Unix/Command/_tar 2 Apr 2001 12:03:50 -0000 1.1 +++ Completion/Unix/Command/_tar 26 Feb 2003 10:26:13 -0000 @@ -13,7 +13,7 @@ # tar itself (GNU tar) # - Things like --directory=... are also completed correctly. -local _tar_cmd tf tmp tmpb del +local _tar_cmd tf tmp tmpb del index # First we collect in `_tar_cmd' single letter options describing what # should be done with the archive and if it is compressed. This @@ -95,24 +95,23 @@ '*=DIR*:directory:_files -/' \ '*=CONTROL*::version control:(t numbered nil existing never simple)' -elif [[ ( CURRENT -gt 2 && "$words[CURRENT-1]" = -*f* && - "$words[CURRENT-1]" != --* && "$words[CURRENT-1]" != -*Cf* ) || - ( CURRENT -eq 3 && "$words[2]" = *f* && "$words[2]" != -* && - "$words[2]" != *Cf* ) || - ( CURRENT -gt 2 && "$words[CURRENT-2]" = -*Cf* && +elif [[ ( CURRENT -gt 2 && "$words[CURRENT-1]" = -[^C]#f* && + "$words[CURRENT-1]" != --* ) || + ( CURRENT -eq 3 && "$words[2]" = [^C]#f* && "$words[2]" != -* ) || + ( CURRENT -gt 2 && "$words[CURRENT-2]" = -*C*f* && "$words[CURRENT-2]" != --* && "$words[CURRENT-1]" != --* ) || - ( CURRENT -eq 4 && "$words[2]" = *Cf* && "$words[2]" != -* ) ]]; then + ( CURRENT -eq 4 && "$words[2]" = *C*f* && "$words[2]" != -* ) ]]; then # ...archive files if we think they are wanted here. _tar_archive -elif [[ ( CURRENT -gt 2 && "$words[CURRENT-1]" = -*Cf*) || - ( CURRENT -eq 3 && "$words[2]" = *Cf* ) ]]; then +elif [[ ( CURRENT -gt 2 && "$words[CURRENT-1]" = -[^f]#C*) || + ( CURRENT -eq 3 && "$words[2]" = [^f]#C* ) ]]; then # a directory for -C - _files -/ + _directories elif [[ ( "$_tar_cmd" = *[xt]* || -n $del ) && -n "$tf" ]]; then @@ -145,6 +144,28 @@ fi _wanted files expl 'file from archive' _multi_parts / _tar_cache_list +elif (( CURRENT == 2 )); then + _values -s '' 'tar function' \ + '(c t u x)A[append to and archive]' \ + '(A t u x)c[create a new archive]' \ + '(A c u x)t[list archive contents]' \ + '(A c t x)u[update archive]' \ + '(A c t u)x[extract files from an archive]' \ + 'v[verbose output]' \ + 'f[specify archive file or device]' else + if ! (( index=$words[(I)-*C*] )); then + if [[ $words[2] = [^f]#C* ]]; then + index=1 + elif [[ $words[2] = *f*C* ]]; then + index=2 + fi + fi + if (( index )); then + index="$~words[index+1]" + [[ $index = (.|..|)/* ]] || index=~+/$index + _files -W $index + else _files + fi fi Index: Completion/Unix/Type/_tar_archive =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_tar_archive,v retrieving revision 1.1 diff -u -r1.1 _tar_archive --- Completion/Unix/Type/_tar_archive 2 Apr 2001 11:41:59 -0000 1.1 +++ Completion/Unix/Type/_tar_archive 26 Feb 2003 10:26:13 -0000 @@ -13,7 +13,7 @@ _description files expl 'archive file' -if [[ "$1" = *[tx]* ]]; then +if [[ "$1" = *[urtx]* ]]; then if [[ "$1" = *[zZ]* ]]; then _files "$expl[@]" -g '*.((tar|TAR).(gz|GZ|Z)|tgz)' elif [[ "$1" = *[Ijy]* ]]; then This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.