Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[(I)-foo] subscripting in _git
- X-seq: zsh-workers 29573
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>, Nikolai Weibull <now@xxxxxxxx>
- Subject: [(I)-foo] subscripting in _git
- Date: Thu, 21 Jul 2011 12:32:53 +0200
- 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=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author