From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5014 invoked by alias); 7 Oct 2015 16:04:03 -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: 36813 Received: (qmail 19923 invoked from network); 7 Oct 2015 16:04:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=cBiwnxyXF8NPOxGwAFetSpvRw/eRsR54IHXvSuiAdOA=; b=fFv9xgI1ARWP2u9et5MC9h3fwOhVG7yjUqU+uvM/fAheh1kbReH/3Svyxcc9VBwQLJ Rr2hNC7xMIi99UNWfWtGob6DqVR4DMUUuUS7Q+XZYHiZqpSAtp5RkT+F5F9GA8x4EqFx ep+lmQzDDjhWX0GOavixwbxTEGOPibIJg7BIw0ZSbfFxn3VbJWfJL7OWlMZWiL0xOD2S wmIgfUgHRkYQ8xBbrCUKq+p09FWDHM5MD35bsLTcjd9x/CzVxDdedvchgSfbLSCSmQqS G9Dsz2YzQOW/E5QQDzN/mmkuvNRqB3gvdGQ3GC7V6m6k0Pqx06woT2N7bu6culhJ4LVV iF+A== X-Gm-Message-State: ALoCoQmoZCCsaGNXDpS16ae1Z1LjsAnb7oFdD7rTtq4Z0zxIyVijUKV3x7tbflcjBr+pPPw+4Qb4 X-Received: by 10.202.72.74 with SMTP id v71mr1195364oia.124.1444233837575; Wed, 07 Oct 2015 09:03:57 -0700 (PDT) From: Bart Schaefer Message-Id: <151007090354.ZM20186@torch.brasslantern.com> Date: Wed, 7 Oct 2015 09:03:54 -0700 In-Reply-To: <20151007163901.03d561ad@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: Possible bug with $~pattern, (#mi)" (Oct 7, 4:39pm) References: <20151007163901.03d561ad@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Possible bug with $~pattern, (#mi) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 7, 4:39pm, Peter Stephenson wrote: } Subject: Re: Possible bug with $~pattern, (#mi) } } On Wed, 7 Oct 2015 17:28:04 +0200 } Sebastian Gniazdowski wrote: } > first one and third one are the same, but only first invocation works. } > Not sure if second one should work: } > } > # a="1234"; beg="#" echo ${a/$~beg(#mi)1/-} } > -234 } > # a="1234"; beg="#"; num=1; echo ${a/$~beg(#mi)$~num/-} } > zsh: bad pattern: #(#mi)1 } } The difference is the first one doesn't have $beg defined at the point } where the expansion takes place OK, but what I think he's trying to achieve is % a="1234" % b="4321" % print ${a/#(#mi)1/-} ${b/#(#mi)1/-} -234 4321 which works and treats the first "#" as part of the ${var//} expansion rather than as part of the pattern. So the complete answer is that there is no way to dynamically insert the beginning marker # or end marker % in ${a/#p/r} or ${a/%p/r} -- they must appear literally, otherwise they become part of the pattern. If you want to do this dynamically, you have to use the extendedglob anchoring syntax rather than the parameter expansion anchoring syntax: % beg='(#s)' % print ${a/$~beg(#mi)1/-}