From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5157 invoked from network); 26 Nov 2005 17:01:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 26 Nov 2005 17:01:11 -0000 Received: (qmail 82249 invoked from network); 26 Nov 2005 17:01:05 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Nov 2005 17:01:05 -0000 Received: (qmail 20870 invoked by alias); 26 Nov 2005 17:00:52 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9711 Received: (qmail 20860 invoked from network); 26 Nov 2005 17:00:51 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 26 Nov 2005 17:00:51 -0000 Received: (qmail 80648 invoked from network); 26 Nov 2005 17:00:51 -0000 Received: from vms044pub.verizon.net (206.46.252.44) by a.mx.sunsite.dk with SMTP; 26 Nov 2005 17:00:49 -0000 Received: from candle.brasslantern.com ([71.116.81.225]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IQK0068KN9BGPL0@vms044.mailsrvcs.net> for zsh-users@sunsite.dk; Sat, 26 Nov 2005 11:00:48 -0600 (CST) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id jAQH0k64000776 for ; Sat, 26 Nov 2005 09:00:46 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id jAQH0k2e000774 for zsh-users@sunsite.dk; Sat, 26 Nov 2005 09:00:46 -0800 Date: Sat, 26 Nov 2005 17:00:46 +0000 From: Bart Schaefer Subject: Re: path and += troubles In-reply-to: <2FDFACEA-C7A6-4F45-897D-B786CC632463@pointcircle.com> To: zsh-users@sunsite.dk Message-id: <1051126170046.ZM773@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <2FDFACEA-C7A6-4F45-897D-B786CC632463@pointcircle.com> Comments: In reply to Steven Klass "path and += troubles" (Nov 25, 9:32pm) On Nov 25, 9:32pm, Steven Klass wrote: } } # Append the path to the end.. } $1+=($2) As you've discovered, this won't work. $1 is not an identifier (it's an identifier dereference) so $1+= is not an assignment. Of course, you need to have a recent-enough version of zsh to support += assignments. For some reason "setopt nullglob" (even cshnullglob) prevents the error message that would otherwise be produced for this line, turning it into a silent no-op. I think that's probably an obscure bug. Anyway, what you need is something like eval $1'+=( $2 )' } # I couldn't figure out how to use ${var#del} That's probably because it's ${var:#del}. eval $1'=( ${(P)1:#$2} )' } 2. How will I handle prepend - I need to do a shift eval $1'=( $2 ${(P)1} )' or (better only for really huge arrays, and watch out for the ksharrays setopt which changes the subscript offset): eval $1'[1]=( $2 ${${(P)1}[1]} )' You're probably better off doing everything in one assignment rather than by having appendPath call deletePath. E.g. appendElem() { eval $1'+=( $2 )' } prependElem() { eval $1'=( $2 ${(P)1} )' } deleteElem() { eval $1'=( ${(P)1:#$2} )' } appendUniq() { eval $1'=( ${(P)1:#$2} $2 )' } prependUniq() { eval $1'=( $2 ${(P)1:#$2} )' }