From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27736 invoked by alias); 31 Jul 2013 19:42:43 -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: 17904 Received: (qmail 12933 invoked from network); 31 Jul 2013 19:42:37 -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 autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at salk.edu does not designate permitted sender hosts) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: globbing in a for loop may prematurely exit script when sourcing a zsh script From: Chris Hiestand In-Reply-To: <20130731100247.441731f2@pwslap01u.europe.root.pri> Date: Wed, 31 Jul 2013 12:42:35 -0700 Cc: zsh-users@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: <76FB9F8A-F28C-46F4-93A9-1D611ABBF026@salk.edu> References: <480F89D7-0191-4D79-B4D8-98E10E80436F@salk.edu> <20130731100247.441731f2@pwslap01u.europe.root.pri> To: Peter Stephenson X-Mailer: Apple Mail (2.1508) On Jul 31, 2013, at 2:02 AM, Peter Stephenson = wrote: > The right thing to do here is tell the shell to expand the pattern to = an > empty string if there are no matches. You can do this without = changing > any options by appending (N) to the pattern, i.e. >=20 > for f in /custom/zsh.d/*.zsh(N); do >=20 > This behaves as if the NULL_GLOB option was set for that pattern. In > zsh (but not necessarily other shells) a "for" loop over an empty > expansion does nothing. Excellent, this is exactly what I was looking for! Thank you, I knew = there must be some way to do it.=