From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8740 invoked from network); 6 Dec 2006 13:43:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Dec 2006 13:43:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 27306 invoked from network); 6 Dec 2006 13:43:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Dec 2006 13:43:20 -0000 Received: (qmail 2369 invoked by alias); 6 Dec 2006 13:43:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11061 Received: (qmail 2358 invoked from network); 6 Dec 2006 13:43:09 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 6 Dec 2006 13:43:09 -0000 Received: (qmail 26141 invoked from network); 6 Dec 2006 13:43:09 -0000 Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by a.mx.sunsite.dk with SMTP; 6 Dec 2006 13:43:04 -0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Grx36-0008D4-Hq for zsh-users@sunsite.dk; Wed, 06 Dec 2006 14:43:00 +0100 Received: from 241.119-84-212.staticip.namesco.net ([212.84.119.241]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 06 Dec 2006 14:43:00 +0100 Received: from david by 241.119-84-212.staticip.namesco.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 06 Dec 2006 14:43:00 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@sunsite.dk From: zzapper Subject: Re: Script breaking on cd *param Date: Wed, 6 Dec 2006 13:42:48 +0000 (UTC) Organization: SuccessTheory Message-ID: References: <200612061226.kB6CQnpu022275@news01.csr.com> X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 241.119-84-212.staticip.namesco.net User-Agent: Xnews/2006.08.24 Sender: news Peter Stephenson wrote in news:200612061226.kB6CQnpu022275 @news01.csr.com: > local str > local -a dirs > for str in param param\* \*param \*param\*; do > # Expands to all matching directories, else nothing. > dirs=(${~str}(N/)) > if (( ${#dirs} == 1 )); then > cd $dirs > break > fi > done PWS Thanx JWTDO but did you forget the dollars on $param? function cdc() { local str local param=$1 local -a dirs echo $param for str in $param $param\* \*$param \*$param\*; do # Expands to all matching directories, else nothing. dirs=(${~str}(N/)) if (( ${#dirs} == 1 )); then cd $dirs break fi done } -- http://successtheory.com/tips/ Vim, Zsh, MySQL Tips