From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIMWL_WL_MED autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id dd988f9c for ; Mon, 24 Dec 2018 05:56:07 +0000 (UTC) Received: (qmail 25794 invoked by alias); 24 Dec 2018 05:55:55 -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: List-Unsubscribe: X-Seq: 43933 Received: (qmail 1818 invoked by uid 1010); 24 Dec 2018 05:55:55 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f42.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(209.85.166.42):SA:0(-1.9/5.0):. Processed in 2.603879 secs); 24 Dec 2018 05:55:55 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=uT6dEgL3CibPRdsFj7sKPZ5/qHGyVpJI3v6arEIz7GI=; b=S0cFmL1mwEQ8tv32mYfpk1YdITwzQjFPfIEvE0SS0bJfYaFng7sD+vIsvnnOU/e7y9 RNqEn3sOYHr+5tR/StcgmKvTTWLty0MVRwcCfm2tqhuFrL73Gx74fiRUx8vGfl0IAZHQ uPd9AATiUjBwuGNy8McRCiKqiYpDCLcvBWLgnKB/39I8SXyfdc3ib8fGoFvt/Yvazx3Z 73IAioyk58TzmZKpPfGAMV2QlkHJdOFrmpUwidzyLDZzw6roD/uOzgneJgo1/Ivx+hL9 3fmj1NgLI9E67DjXS65M4sx6VjgOOZHC27aN0ar5oWCBanzEMHx/2tID+vLO22jhVT0J gWSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=uT6dEgL3CibPRdsFj7sKPZ5/qHGyVpJI3v6arEIz7GI=; b=o3sOmoFQ6nv21sTLJSVnh8DHNS9pHZ0LD1xaLBCtWmGnl4YzB2RbffXjjzu0erZ8Fv g/P4W9GeFmUCGMPMHRu043uPSI4FkguPmqZuFSVeSU1A01V4YupJ20J3cVdkXhqAFtxC 4+za8Yc2QFFck81eEAvT/lLgXDbahTm5dC+ELBPjgjmvBktrolP3LLoVrtbv9Wkt9q05 AjzwSD0cIkWF2ORKMkrajd16KaWNyhRmZMt0icfRZwgMjpStA6p5HTDikWHA6X5C9g2y clREM1lSyttYth3IpGzVTqnjjwKWCpebSDJ+gS6RjTw6m5wxVEX8LgQHDwcE0NNb4iUc 5xKA== X-Gm-Message-State: AJcUukcQkjqB9DwrwJscWqwCvw4wfCg+JOLqprtAOeO/yt1fCvhEC2JL POOEdKQztgTZmyrjU4ng+Qecnw== X-Google-Smtp-Source: ALg8bN4caE8op8o2TJFysx/1Gn77WBQ7ky7XocdvQKjxrW/Vh8Ei16gEKsWXEXgBzOzjJ83FQtGeow== X-Received: by 2002:a6b:398b:: with SMTP id g133mr8144799ioa.67.1545630949438; Sun, 23 Dec 2018 21:55:49 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: Re: possible bug in _arguments? From: dana In-Reply-To: Date: Sun, 23 Dec 2018 23:58:12 -0600 Cc: zsh-workers@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: <38768425-6F37-4C96-8071-F97B2C97180B@dana.is> References: To: Max Katsev X-Mailer: Apple Mail (2.3445.100.39) On 23 Dec 2018, at 16:34, Max Katsev wrote: >Is this a bug or am >I missing something? Is there another way to get what I want? I don't think optional-operand specs work like that. AFAIK, when a spec = for an optional operand n appears before one for a required operand n+1, all it = tells zsh is that it should offer both sets of possibilities at the = command-line position corresponding to n. You have to figure out yourself what to do = with an earlier operand once you're past that position. If the command is as simple as you said, you can just do something like = this: local required (( CURRENT > 2 )) && [[ $words[2] =3D=3D optional ]] && required=3D':cmd2:(required)' _arguments : ':cmd1:(optional required)' $required '*:other = args:_files' If you also need to support options, you can use the *:: form: local ret=3D1 required local -a context line state state_descr local -A opt_args _arguments : -a -b -c '*:: :->next' && ret=3D0 [[ $state =3D=3D next ]] && { words=3D( fake "${(@)words}" ) (( CURRENT++ )) (( CURRENT > 2 )) && [[ $words[2] =3D=3D optional ]] && required=3D':cmd2:(required)' _arguments : \ ':cmd1:(optional required)' $required '*:other args:_files' \ && ret=3D0 } return ret Something like that, at least; there are lots of ways you could handle = it dana