[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pattern replacement inconsistency

From: Chet Ramey
Subject: Re: Pattern replacement inconsistency
Date: Wed, 30 May 2007 08:58:56 -0400

> Bash Version: 3.2
> Patch Level: 17
> Release Status: release
> Description:
> If a is an array, ${a[*]//%pattern/replacement} and 
> ${a[*]//#pattern/replacement} don't work. Both do nothing. The single-slash
> versions ${a[*]/%pattern/replacement} and ${a[*]/#pattern/replacement} work
> as expected.

Anchored pattern matches that specify removing or replacing each match
don't make sense.  The combination is meaningless.

> One could argue about using // in this context, but anyway the behavior is
> inconsistent in 2 ways:

On the other hand, it's consistent with other shells implementing the feature.
There's no reason to be deliberately incompatible.

> - The double-slash versions worked in 3.1.

It was explicitly removed in bash-3.2 as the result of a bug report --
it's in the change log. 

> - The double-slash versions work in 3.2 if the pattern does _not_ start 
> with % or #.

Of course -- then they are not anchored. :-)


``The lyf so short, the craft so long to lerne.'' - Chaucer
                                Live Strong.
Chet Ramey, ITS, CWRU    address@hidden    http://tiswww.tis.case.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]