help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Things like ${parameter^} only works with path expansion


From: Peng Yu
Subject: Re: [Help-bash] Things like ${parameter^} only works with path expansion?
Date: Sat, 11 Apr 2015 11:56:17 -0500

On Sat, Apr 11, 2015 at 11:33 AM, Pierre Gaston <address@hidden> wrote:
>
>
> On Sat, Apr 11, 2015 at 7:11 PM, Peng Yu <address@hidden> wrote:
>>
>> On Sat, Apr 11, 2015 at 11:08 AM, Pierre Gaston <address@hidden>
>> wrote:
>> >
>> >
>> > On Sat, Apr 11, 2015 at 6:45 PM, Peng Yu <address@hidden> wrote:
>> >>
>> >> Hi,
>> >>
>> >> The manual says things like ${parameter^} only works with path
>> >> expansion. I just want to make sure I understand it correctly. Pattern
>> >> Matching does not work here, right (as demonstrated by the following
>> >> example)?
>> >>
>> >> parameter=abcABC123ABCabc
>> >> echo "${parameter,,@(abcABC123ABCabc|ABCABC123ABCABC)}"
>> >>
>> >> Why this construct does not accept pattern matching, but things like
>> >> ${var%%pattern} does? Is it better to make them consistent to avoid
>> >> confusions?
>> >>
>> >> --
>> >> Regards,
>> >> Peng
>> >>
>> >
>> > The pattern after ,, and ^^ only matches one character at a time
>>
>> I don't see this documented in the man page. Is there something
>> missing in the man page?
>>
> my version says:
>
> Case modification.  This expansion modifies the case of alphabetic
> characters in parameter.  The pattern is expanded  to  produce  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.  The pattern should not attempt to match more than one
> character.

OK.

I just notice that the manual says "Each  character in the expanded
value of parameter is tested against pattern, and, if it matches the
pattern, its case is converted." But the following example shows that
',' only allow the match of the first character. Is there anything
wrong with the manual or I don't understand it correctly?

x=ABC
echo "${x,A}"
echo "${x,B}"
echo "${x,,B}"

-- 
Regards,
Peng



reply via email to

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