Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible bug with $~pattern, (#mi)
- X-seq: zsh-workers 36812
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Possible bug with $~pattern, (#mi)
- Date: Wed, 07 Oct 2015 16:39:01 +0100
- In-reply-to: <CAKc7PVBFT+rxO5qEMKRQWL=vehesMENbgi-7Ano1FurA6O1CUQ@mail.gmail.com>
- 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
- Organization: Samsung Cambridge Solution Centre
- References: <CAKc7PVBFT+rxO5qEMKRQWL=vehesMENbgi-7Ano1FurA6O1CUQ@mail.gmail.com>
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