bug-bash
[Top][All Lists]
Advanced

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

Re: Problem with pattern replacing when STRING is an expandable char


From: Heinz-Ado Arnolds
Subject: Re: Problem with pattern replacing when STRING is an expandable char
Date: Thu, 13 Dec 2007 09:17:31 +0100
User-agent: Thunderbird 1.5.0.13 (X11/20070809)

Paul Jarc wrote:
Heinz-Ado Arnolds <arnolds@MPA-Garching.MPG.DE> wrote:
    a=111.1
    echo ${a//[0-9]/x}

    correctly gives "xxx.x", but

    echo ${a//[0-9]/*}

    gives a listing of files in current directory. Seems that the "*"
    is expanded before replacing the pattern.

No, it's expanded afterward, because the variable expansion isn't
quoted.  This does what you want:
    echo "${a//[0-9]/*}"

    It workes the right way at least up to bash-3.1.17(1)-release

    But if you set

    a=111

    it doesn't even work in 3.1.17 right.

3.1.17 behaves the same way as 3.2.25.  You see a different result
because of a different set of files between the two situations, not
because of the different bash version.  If there are no files in the
current directory that match ***.*, then pathname expansion will leave
it unchanged.


paul

Thanks a lot for your fast response! Ok, even after so many years
bash is astounding if you don't have all expansion rules in mind
every time.

Kind regards,

Ado





reply via email to

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