From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10010 invoked by alias); 19 Jan 2015 15:58:17 -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: 19747 Received: (qmail 10118 invoked from network); 19 Jan 2015 15:58:05 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1421682670; bh=dt4hqiZNL0gV3i5bqm7MaWE6jVfW1oLTUBUZDeZV66A=; h=From:To:In-Reply-To:References:Subject:Date; b=Nh/1XNQWVbJg07I57dvmJ1m0kIQewBeYEzT66ESadzZS3CNMZGZZqD6PPPsW/VJ3x lTn13DXXuI/Hzq+WYUVkzQ7t7tN73Uul0ZhxrnKzVkzYZpe0CaJJYijM71bQD4Ds04 snGEkS5M47WinAIxEvkgP33tCMOco1L4IZUCDWwQ= From: ZyX To: Eric Cook , "zsh-users@zsh.org" In-Reply-To: <54BC1B8E.5080806@gmx.com> References: <54BC1B8E.5080806@gmx.com> Subject: Re: Equivalent of set -- *(DN) in sh MIME-Version: 1.0 Message-Id: <1102431421682670@web6h.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Mon, 19 Jan 2015 18:51:10 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 18.01.2015, 23:53, "Eric Cook" : > 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 .. `..foo` is a valid name, but it is being excluded. You need to add `'.??*'` to the list of patterns. >   if match $pat; then >     set -- "$@" $pat >   fi > done > unset pat > > test "$#" -gt 0 && printf '%s\n' "$@"