help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Case modification


From: Stephane Chazelas
Subject: Re: [Help-bash] Case modification
Date: Tue, 3 Jan 2012 21:34:40 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

2011-12-24 15:48:42 -0500, Chet Ramey:
> On 12/23/11 7:02 PM, Bill Gradwohl wrote:
> 
> > Therefore, pattern (can not be / should not be) more than 1 character,
> > unless its within [ ] then each character gets its turn. Reading the man
> > page does not give me that impression. It hints at it, but is nebulous
> > enough to allow other interpretations.
> 
> Let's see how we can make the documentation clearer.  I think it takes only
> these two additional sentences in the description:
> 
> "Each character in the expanded value of @var{parameter} is tested against
> @var{pattern}, and, if it matches the pattern, its case is converted.
> The pattern should not attempt to match more than one character."
> 
> And, for what it's worth, the number of characters in a [...] pattern does
> not matter: a bracket expression can only ever match a single character.
[...]

What's the rational behind such a contrieved operator, BTW.

For comparison, in zsh, there are:

Using expansion flags:

~$ a='foo BAR'
~$ echo ${(U)a}  # upper
FOO BAR
~$ echo ${(L)a}  # lower
foo bar
~$ echo ${(C)a}  # capitalise
Foo Bar

Or if you do need to convert only some letters (but why would you?):
~$ echo ${a//(#m)[oa]/${(U)MATCH}}
fOO BAR

Or, a la csh/tcsh:

~$ echo $a:l
foo bar
~$ echo $a:u
FOO BAR

(those modifiers can also apply to history expansion and in globbing qualifiers)

-- 
Stephane




reply via email to

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