From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28591 invoked by alias); 21 Jul 2011 10:33:00 -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: 29573 Received: (qmail 10173 invoked from network); 21 Jul 2011 10:32:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.212.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=DjJXld7g5G+YLjTDxGuvQ9oSq0tdz98FsQ8M1nN4CIY=; b=feGwEONOBClsxPJUdGlwWp+AJ8SLYw+MdN6dOUpJQ5Tg9PRC+WKw1bg3hfwmjVwHR8 fVn9idSLb3WoABS2Jq9l8L/pmhKg0y1Ri2u9fb+7uNYXJmBvEzhfn6UhM0iQABSI1GS6 jVcJjD8NbNnceZhfUDhryfrg1NBztf40Iu+dU= MIME-Version: 1.0 Date: Thu, 21 Jul 2011 12:32:53 +0200 Message-ID: Subject: [(I)-foo] subscripting in _git From: Mikael Magnusson To: zsh workers , Nikolai Weibull Content-Type: text/plain; charset=UTF-8 I noticed while looking at _git-add that _git does a lot of this type of thing: if (( words[(I)-n|--dry-run] )); then that particular example is fine, but further down is this if [[ -n ${line[(I)-f|--force]} ]]; then which seems to have two problems, first it uses line instead of words, so it never matches. Second it uses [[ -n ]] which will always be true as (I) returns a 0 when it didn't match. There appears to be other occurences of this pattern in the file, and before I go changing all of them I wanted to ask if I missed something obvious? It also looks like _arguments changes $words, as I had to do this to make it work. @@ -38,6 +38,8 @@ _git-add () { local curcontext=$curcontext state line declare -A opt_args + local -a owords + owords=($words) @@ -63,7 +65,7 @@ _git-add () { (file) # TODO: Use __git_ignore_line_inside_arguments. declare -a ignored_files_alternatives - if [[ -n ${line[(I)-f|--force]} ]]; then + if (( ${owords[(I)-f|--force]} )); then ignored_files_alternatives=( -- Mikael Magnusson