From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27327 invoked by alias); 7 Nov 2013 15:06:46 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18115 Received: (qmail 19634 invoked from network); 7 Nov 2013 15:06:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <131107070640.ZM20932@torch.brasslantern.com> Date: Thu, 07 Nov 2013 07:06:40 -0800 In-reply-to: <527B336A.40506@gmail.com> Comments: In reply to John "Re: ordering of file-patterns completions" (Nov 6, 11:30pm) References: <527A5F11.2080701@gmail.com> <131106080319.ZM19160@torch.brasslantern.com> <527AE8BF.6090706@gmail.com> <131106201745.ZM20201@torch.brasslantern.com> <527B336A.40506@gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: ordering of file-patterns completions MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Nov 6, 11:30pm, John wrote: } > } > If there's nothing but options, for example, then you can probably do: } > } > local first_file=$(( ${words[(I)-*]} + 1 )) } > } The first one nearly does it, but seems to be confused when there are no } options at all. Ah, yes. Because it's counting backwards it will run down to zero if it finds nothing. I listed that one first because it was the simplest expression, but I should have stuck with the second one: } > local first_file=$(( ${${words[2,-1]}[(i)[^-]*]} + 1 )) [...] } I ended up adding: } } if [[ $first_file -lt 2 ]]; then } first_file=2 } fi } } And that fixed it. Not realizing that the array was 1-based threw me } for a bit. I also changed the :x to a :e, as :x just gave me an error, } and :e matched the description of what I think you had meant. Oops, yes, I did mean :e. Typo'd it earlier and then just kept copy- pasting.