From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6471 invoked by alias); 18 Jan 2015 20:51: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: 19744 Received: (qmail 140 invoked from network); 18 Jan 2015 20:51:31 -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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Message-ID: <54BC1B8E.5080806@gmx.com> Date: Sun, 18 Jan 2015 15:46:06 -0500 From: Eric Cook User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: zsh-users@zsh.org Subject: Re: Equivalent of set -- *(DN) in sh References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:EM0fUv3JiG0yrq7TKCITh408XRNSEjI4WgQDHnUjS77BNSdpfmZ zMk3jDES+IXqDUfKtf3moZ9IEvwRtY+GZzBqmOC9GW0BzswazglLufhcp5Ctg65Hf8z6Uif +qepHXITxVyn89WmFxmaIK3Ekh19ZlAYi1jVzAH322cb11VWWaXUZeUz8+XhTShwK4NQjgH duJELs1bbvysavNfr6EWg== X-UI-Out-Filterresults: notjunk:1; On 01/18/2015 01:28 PM, Nikolai Weibull wrote: > Hi! > > Is there any way to get the equivalent of Zsh’s > > set -- *(DN) > > in sh? Most important here would be NULL_GLOB, as, by default, sh > simply leaves the * if there are no files to match. > > Thanks! match() { test "$#" -gt 2 && return test -e "$1" && return return 1 } set -- for pat in '.[^.]*' '*'; do # *(DN) ignores . and .. if match $pat; then set -- "$@" $pat fi done unset pat test "$#" -gt 0 && printf '%s\n' "$@"