From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15778 invoked by alias); 14 May 2014 07:18:33 -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: 18797 Received: (qmail 19744 invoked from network); 14 May 2014 07:18:17 -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: <140514001819.ZM23478@torch.brasslantern.com> Date: Wed, 14 May 2014 00:18:19 -0700 In-reply-to: <20140514041908.GF2471@tarsus.local2> Comments: In reply to Daniel Shahaf "Re: globbing in conditional expressions" (May 14, 4:19am) References: <20140507124101.GA53652@isis.sigpipe.cz> <20140507154407.660eb500@pwslap01u.europe.root.pri> <20140508105522.GE2052@tarsus.local2> <20140508122045.3c68c3fa@pwslap01u.europe.root.pri> <140508083418.ZM14713@torch.brasslantern.com> <20140508201936.GB53652@isis.sigpipe.cz> <140513084117.ZM22925@torch.brasslantern.com> <20140514041908.GF2471@tarsus.local2> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: globbing in conditional expressions MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On May 14, 4:19am, Daniel Shahaf wrote: } } > You could define (via zmodload) an operator that applies filename } > generation to its argument, but changes to the internals of globbing } > would be needed to make a short-circuit happen. Then those changes } > would have to be exposed somehow so that the operator could use them. } } I've taken a shot at making those changes, see attached. Interesting! A few thoughts just reading through the patch: I'm very curious why you chose to insert a new parameter in the middle of the globlist() and zglob() signatures, instead of appending it. The way we'd have typically done this in the past would be to keep the old call signature as it was and introduce a new entry point with the new signature, to isolate the changes to as few files as possible. This also makes it easier to match meaningful changes to the commits that made them, given that nearly all of the changes in the calls are not changes of semantics. (The main body of the old function would become the body for the new call signature, to which the old signature would then call through. On the other hand, that does lead to some clutter, so I don't really feel that strongly either way.) The strspn(..., "abcdefghkmnoprstuwxzLONGS") probably should NOT have the "m" added to them, because those are intended to be identifying operators that are defined by POSIX "test". It'd be a bit difficult to use [ -m ... ] anyway because the glob pattern would expand before the call to the test builtin. Do I read correctly that "shortcircuit" also means "don't return any file names, just return an indication of whether there is such a file" ?? (Since you don't allocate the matchbuf array when shortcircuit.) If so, there might be a more descriptive name for it, "search_only" or something. The test [[ -m zero* ]] && [[ ! -m *nonexistent* ]] could be written [[ -m zero* && ! -m *nonexistent* ]] -- if that doesn't parse (I see no reason to think it wouldn't) then something is wrong. Did you check path searches like **/zero* and whether glob flags work right? I may give this patch a try tomorrow sometime.