From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1808 invoked by alias); 10 Apr 2016 22:10:01 -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: 38266 Received: (qmail 1226 invoked from network); 10 Apr 2016 22:09:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=Y8GpTYvv/qkf3CBtccKZw49dk6UdOmbEUECrhBCu0Zk=; b=Gd2UpoHJWZOJeBUdN1V6Ud6aGcnLO5oVUfX40xFnsIsAYSp7uaoAtAp5hbIdQbX6nJ wxCB36Qack3NaKpSVGg7IAgv2oVVu19yrzje52ryaeuS0TIBMYCZJAQ8SROJaanlLU8J krlUyOu8ojdsEd57YSZR3im6a8I5RhDyJcyKApE+H0WzS4MXbVe5/cUQKDtTnyUQljO+ tmkloTMZ/VVXzE6oySHWUOKopASjVnwG9noF6w7VNQq0o/K3kBmbVE40Sz0WvEPRqx4R aJQ/DMKdSHD8bFubX9suV68fsrl113hlI1wDSAyNUfVYq7zrjfmG2ix59BirKJ7D08/f HkwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=Y8GpTYvv/qkf3CBtccKZw49dk6UdOmbEUECrhBCu0Zk=; b=VMdIuhtFyRPRyqonajjVeS8yqEmuZoXq8tGlUHmrTsUzB27B/ji892XAh6ItdKa3Xl oWbveuRBerrdaxUcwW8Sol2XfYKgJrCuzCyf/vnlHJZJccplKU2dtovIAxaO84DbAfAQ HfaaPjEfe6AXZTPmX3+qLNXA2KwsqDWbfXfETPbmmAU+aECndmamJhC7PFscDnhg1izC zhV/grNxY23yEVBZWiZEji8ciaLG01pNhHZtReNfOthx3i2/zXzEtGNSzl65U2jKjtsf 4xNFT/B/6nKyppvt06RIQbvBFyfaEFijaYh3H7t/HHxfQMUDtnGNC+2V/dDryoRxWtAv xfNA== X-Gm-Message-State: AD7BkJItXrvBoKdxUAq7tmC/cE1qUxtQ+0hEoL3uYMqeADFrDhxZ7Ec0GhcybP6Irp9YzQ== X-Received: by 10.98.16.93 with SMTP id y90mr28731825pfi.155.1460326196216; Sun, 10 Apr 2016 15:09:56 -0700 (PDT) From: Bart Schaefer Message-Id: <160410151105.ZM21544@torch.brasslantern.com> Date: Sun, 10 Apr 2016 15:11:05 -0700 In-Reply-To: Comments: In reply to Mikael Magnusson "Allow slash in alternation patterns in limited cases?" (Apr 10, 10:36pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh workers Subject: Re: Allow slash in alternation patterns in limited cases? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 10, 10:36pm, Mikael Magnusson wrote: } } /path/(to/file|or/another/file) # nope, too hard } (/path/to/a/dir/*|/path/to/some/other/files/*) # can we allow this? My gut feeling is that this is close to impossible. In fact your first example might actually be easier than your second, because there are no pattern characters within the alternation. Similarly I think (/path/to/a/dir|/path/to/some/other/files)/* would be easier than the case where the wildcard is inside the parens, because an opendir() might be forced on each fixed path. } If not, would it be possible to invent some new syntax to "paste" two } or more globs together so that a single set of glob } quals/sorts/flags/subscripts could apply to it? Syntactically, this would probably work best as a parameter expansion flag, which accepts a glob qualifier and applies it to every value in the (array) expansion. I'm not sure if there are any letters left for this; we've reserved (_:stuff:) for future use, so possibly something like e.g. ${(_:#qom[1]:)array} would work. I insert the #q so that other stuff in (_:stuff:) might still be adopted in future. (Also is the above equivalent to ${${(_:#qom:)array}[1]} and if so do we prohibit the qualifier subscripting in this form?) Internally, to make this fly, the glob.c:zglob() function must be factored apart into the bit that parses glob flags, the bit that makes the call to scanner() [which would get called in a loop over the array elements], and finally the bit that handles gf_sortlist and makes the calls to insert_glob_match(). This is probably a significant effort because of the use of C globals for glob state [although that might be easier since workers/38188]. Of course readability takes a major dive here as we're mating together our two most cryptic bits of syntax into a single monster. The only other idea I have is to use a command form like zglob -q 'om[1]' $array which to substitute-in place like a normal glob would need to be written echo $(zglob -q 'om[1]' $array) which for efficiency would mean we implement the ksh-style non-fork of builtins appearing in $(...), and now we're down another rabbit hole.