From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1739 invoked from network); 11 Feb 2006 17:38:38 -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; 11 Feb 2006 17:38:38 -0000 Received: (qmail 91385 invoked from network); 11 Feb 2006 17:38:32 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Feb 2006 17:38:32 -0000 Received: (qmail 24467 invoked by alias); 11 Feb 2006 17:38:29 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22226 Received: (qmail 24457 invoked from network); 11 Feb 2006 17:38:28 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Feb 2006 17:38:28 -0000 Received: (qmail 91169 invoked from network); 11 Feb 2006 17:38:28 -0000 Received: from smtpout0179.sc1.cp.net (HELO n066.sc1.cp.net) (64.97.136.179) by a.mx.sunsite.dk with SMTP; 11 Feb 2006 17:38:27 -0000 Received: from sc (82.26.164.81) by n066.sc1.cp.net (7.2.069.1) id 43C54FAD003837F9 for zsh-workers@sunsite.dk; Sat, 11 Feb 2006 17:38:24 +0000 Received: from chazelas by sc with local (Exim 3.36 #1 (Debian)) id 1F7yhP-0001yr-00 for ; Sat, 11 Feb 2006 17:38:19 +0000 Date: Sat, 11 Feb 2006 17:38:19 +0000 From: Stephane Chazelas To: Zsh-workers Subject: Re: Regexp replace on all arguments. Message-ID: <20060211173818.GA4965@sc> Mail-Followup-To: Zsh-workers References: <20060211173626.GA6863@lxlabs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20060211173626.GA6863@lxlabs.com> User-Agent: Mutt/1.5.6i Sender: Stephane Chazelas On Sat, Feb 11, 2006 at 11:06:26PM +0530, Ligesh wrote: > > Hi folks, > > I want to replace all occurrences of say '/c/' in the arguments with 'c:'. Could someone help me with completing the function below. > > winexec () { > > // First loop through all arguments and replace > > foreach arguments $2 to $- { > replace ^/c/ with c: , ^/d/ with d: etc. (The character c, d should be preserved, '^' means beginning of the word.) > } > > execute $1 with the new arguments. > > } > > The execution would be > > $ winexec cacls.exe /c/name-of-file [...] winexec() { local cmd=$1 shift || return argv=("${@//#\/(#b)([a-zA-Z])\//$match:}") "$cmd" "$@" } -- Stéphane