help-bash
[Top][All Lists]
Advanced

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

Re: $${a,b} brace expansion flaw.


From: alex xmb sw ratchev
Subject: Re: $${a,b} brace expansion flaw.
Date: Sat, 20 Jan 2024 23:32:01 +0100

~ $ a=BaNaNa ; echo ${a,N}
BaNaNa
~ $ a=BaNaNa ; echo ${a,,N}
Banana

i d say that says pattern for , is only-from-beginning
and for ,, its really a 'pattern'

On Sat, Jan 20, 2024, 23:25 Greg Wooledge <greg@wooledge.org> wrote:

> On Sat, Jan 20, 2024 at 08:55:51PM +0100, Paxsali via wrote:
> > echo ${a,b}
> >
> > I have the latest bash reference manual in front of me and I cannot find
> > this form of brace or shell parameter expasion.
>
>        ${parameter^pattern}
>        ${parameter^^pattern}
>        ${parameter,pattern}
>        ${parameter,,pattern}
>               Case  modification.   This expansion modifies the case of
> alpha‐
>               betic characters in parameter.  The pattern is expanded to
> pro‐
>               duce a pattern just as in pathname expansion.  Each
> character in
>               the expanded value of parameter is tested against pattern,
> and,
>               if  it  matches the pattern, its case is converted.
>
> What this expansion would do, therefore, is convert all of the 'b'
> characters in the value of $a to lowercase.  Since 'b' is already
> lowercase, it would be a no-op.
>
> Nevertheless, it is valid syntax.
>
> Here's a similar example that actually does something:
>
> unicorn:~$ a=Banana
> unicorn:~$ echo "${a,B}"
> banana
>
>


reply via email to

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