From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29716 invoked by alias); 3 Mar 2013 18:42:43 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31107 Received: (qmail 5130 invoked from network); 3 Mar 2013 18:42: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 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130303104236.ZM5215@torch.brasslantern.com> Date: Sun, 03 Mar 2013 10:42:36 -0800 In-reply-to: <87bob0o8au.fsf@gmail.com> Comments: In reply to Christian Neukirchen "Re: globbing problem" (Mar 3, 3:40pm) References: <20130303092908.0562f2d1__42920.4312772073$1362301372$gmane$org@arcor.com> <87bob0o8au.fsf@gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: globbing problem MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Mar 3, 3:40pm, Christian Neukirchen wrote: } Subject: Re: globbing problem } } Manfred Lotz writes: } } > function lsd() { } > if (( $# > 0 )); then } > ls -d "$*"(/) } > else } > ls -d *(/) } > fi } > } } > } > alias lsd='noglob lsd' } } You need to force globbing. Try this: } } lsd() { local -a pat; pat=(${^*:-*}'(/N)'); ls -d ${~pat} } } } (How to do it without a temporary variable?) By simply doing it without a temporary variable! lsd() { ls -d ${^~*:-*}(/) } If you throw in the (N) like Christian did, "lsd notadirectory" will give you "./" which may or may not be what you want. If you want to be able to handle other "ls" options ("lsd -l m*") then you'll need temporaries to capture the options and patterns separately. But handling all the possible options of "ls" is a large task all by itself ...