From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12969 invoked by alias); 31 May 2014 04:43:41 -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: 18866 Received: (qmail 7095 invoked from network); 31 May 2014 04:43:39 -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: <140530214320.ZM30732@torch.brasslantern.com> Date: Fri, 30 May 2014 21:43:20 -0700 In-reply-to: <140530085542.ZM18304@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: globbing in conditional expressions" (May 30, 8:55am) References: <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> <140514001819.ZM23478@torch.brasslantern.com> <20140515092901.GC2174@tarsus.local2> <140515075003.ZM28035@torch.brasslantern.com> <20140526235216.GC1920@tarsus.local2> <140529205956.ZM17410@torch.brasslantern.com> <20140530094752.4a116629@pwslap01u.europe.root.pri> <140530085542.ZM18304@torch.brasslantern.com> 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 30, 8:55am, Bart Schaefer wrote: } } Is there a non-convoluted way to have the special case of a glob with } BOTH of the (NY) qualifiers return empty string rather than nularg when } it finds no match? Empty string is an illegal file name so for most } purposes it wouldn't otherwise affect usage. This turns out to be pretty simple. It'd additionally be nice if the CSH_NULL_GLOB option caused any such empty strings to be removed when some other pattern succeeds, but that seems rather far-reaching. (The following will require a tweak to Daniel's test in D02glob.) diff --git a/Src/glob.c b/Src/glob.c index 07dd7c2..5aa306b 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -1748,6 +1761,11 @@ zglob(LinkList list, LinkNode np, int nountok) matchptr++; matchct = 1; } + } else if (shortcircuit) { + /* treat as an empty string */ + matchptr->name = dupstring(""); + matchptr++; + matchct = 1; } if (!(gf_sortlist[0].tp & GS_NONE)) {