[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: case modification won't work with pattern
From: |
Chet Ramey |
Subject: |
Re: case modification won't work with pattern |
Date: |
Thu, 10 Mar 2011 22:33:24 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 |
On 3/10/11 9:04 PM, Clark J. Wang wrote:
> On Thu, Mar 10, 2011 at 9:31 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
>
>> On Thu, Mar 10, 2011 at 10:22:12AM +0800, Jerry Wang wrote:
>>> var="abcabc"
>>> echo "var: ${var}"
>>> echo "replace the leading \"ab\" to uppercase: ${var^ab}" # expect
>> to get "ABcabc" ?
>>
>> The documentation is a bit terse, admittedly.
>
>
> Agree. Almost all of the poeple around me don't understand why it works that
> way. Maybe some background of the feature requirement can help us to
> understand better.
The original requests were for a way to change the first letter or
every letter to uppercase or lowercase, like ksh typeset -l/-u, using
word expansion syntax (one request was for a new builtin command to
do it). That's what you get if you don't use the pattern part of the
expansion. I invented the pattern following the case specifier to allow
each character to be separately modified.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/