Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible bug with $~pattern, (#mi)
- X-seq: zsh-workers 36814
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: Possible bug with $~pattern, (#mi)
- Date: Wed, 7 Oct 2015 18:06:43 +0200
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=9AiqDUMHJBDvlWrpfY9JY9Bz6QpjeitoSJzSUe+9wOU=; b=pS7nOTHobQWDQiLgoeourAvop/19MYxpJCM5ENDbSa9z+K2mhJD4kr+Iyk/ucXsDyw 2/gyHkekom/pENhwEyEjKkPjK6QDjW09xKO5LO7P+a0nbMTOOVoxKtWCI/u8Q8gizaTN 0RKbf7Cg4pHo18QkxsdKHAEziqvOdYzJBLz3X2V8fKMu+EgzKOkpxDK7BGKgROpnUhn2 +hSjTF0siCrvUODi4btUrwTZ8Nzmg7QnHE9cY0BW/fK+FPNMldPA+BdHq3GuK7W+tmNT 6bnly2Df77brsuXbM+1uOLe2oPiLcIETG+Y9BLUkW5HuoeTTRy2pK+fh7KBQ+0++u8tP /XYg==
- In-reply-to: <20151007163901.03d561ad@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBFT+rxO5qEMKRQWL=vehesMENbgi-7Ano1FurA6O1CUQ@mail.gmail.com> <20151007163901.03d561ad@pwslap01u.europe.root.pri>
True, beg wasn't set in first invocation. However pattern #(#mi)1 is correct:
# a="1234"; echo ${a/#(#mi)1/-}
-234
When beg is used (this time correctly):
# a="1234"; beg="#"; echo ${a/$~beg(#mi)1/-}
zsh: bad pattern: #(#mi)1
Best regards,
Sebastian Gniazdowski
On 7 October 2015 at 17:39, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Wed, 7 Oct 2015 17:28:04 +0200
> Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> 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
>> # a="1234"; beg="#" echo ${a/$~beg(#mi)1/-}
>> zsh: bad pattern: #(#mi)1
>> #
>
> The difference is the first one doesn't have $beg defined at the point
> where the expansion takes place, because beg is being put into the
> environment to use when the command is run. The environment of the
> command is not the same thing as the set of variables avaiable to the
> shell for preparing the command line.
>
> So what you're executing that works is actually
>
> a="1234"
> echo ${a/(#mi)1/-}
>
> After that, the result is self explanatory --- #(#mi) is a bad pattern
> (with EXTENDED_GLOB set).
>
> pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author