bug-bash
[Top][All Lists]
Advanced

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

Re: case modification won't work with pattern


From: Clark J. Wang
Subject: Re: case modification won't work with pattern
Date: Thu, 10 Mar 2011 16:54:01 +0800

On Thu, Mar 10, 2011 at 10:22 AM, Jerry Wang <
Jerry.J.Wang@alcatel-lucent.com> wrote:

> Configuration Information [Automatically generated, do not change]:
> Machine: i486
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu'
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib
> -g -O2 -Wall
> uname output: Linux Xubuntu 2.6.31-22-generic #73-Ubuntu SMP Fri Feb 11
> 17:36:01 UTC 2011 i686 GNU/Linux
> Machine Type: i486-pc-linux-gnu
>
> Bash Version: 4.0
> Patch Level: 33
> Release Status: release
>
> Description:
>        The case modification won't work with pattern.
>        I have a simple script a.sh, please see below:
>
>        #! /bin/bash
>        var="abcabc"
>        echo "var: ${var}"
>        echo "replace the leading \"ab\" to uppercase: ${var^ab}" # expect
> to get "ABcabc" ?
>        echo "replace all the \"ab\" to uppercase: ${var^^ab}"    # expect
> to get "ABcABc" ?
>
>        echo "replace the first \"a\" to uppercase: ${var^a}"
>

And here it actually replaces the *leading* `a' other than the *first* `a'.


>        echo "replace all \"a\" to uppercase: ${var^^a}"
>
>        Then the result is:
>
>        mylogin@Xubuntu:~/shell$ ./a.sh
>        var: abcabc
>        replace the leading "ab" to uppercase: abcabc   --> incorrect
>        replace all the "ab" to uppercase: abcabc           --> incorrect
>        replace the first "a" to uppercase: Abcabc              --> correct
>        replace all "a" to uppercase: AbcAbc                    --> correct
>
>
> Repeat-By:
>
> --
> Jerry Wang jerry.j.wang@alcatel-lucent.com
>
>


-- 
Clark J. Wang


reply via email to

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