[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with pattern replacing when STRING is an expandable char
From: |
Paul Jarc |
Subject: |
Re: Problem with pattern replacing when STRING is an expandable char |
Date: |
Wed, 12 Dec 2007 14:49:38 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
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