bug-bash
[Top][All Lists]
Advanced

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

bash-3 incompatibility: quoting in pattern substitution of variables


From: koenig
Subject: bash-3 incompatibility: quoting in pattern substitution of variables
Date: Mon, 6 Sep 2004 13:35:49 +0200

Configuration Information [Automatically generated, do not change]:
Machine: i386-linux
OS: RedHat-7.1
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386-linux' 
-DCONF_OSTYPE='RedHat-7.1' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' 
-DLOCALEDIR='/scr/os-rh71/koenig/bash-3.0/PREINSTALL//share/locale' 
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H  -I.  -I/soft/bash/bash-3.0/bash-3.0 
-I/soft/bash/bash-3.0/bash-3.0/include -I/soft/bash/bash-3.0/bash-3.0/lib   -O2 
-D_LARGE_FILES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
uname output: Linux turtle 2.4.24-2 #2 Fri Feb 6 09:34:22 CET 2004 i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 3.0
Patch Level: 0
Release Status: release

Description:

the following sequence (trying to replace all '?' to ' ')
from bash-2.05b doesn't work anymore:

        $ a="a?b?c"
        $ echo ${a//\\?/ }
        a?b?c
        $ echo "${a//\\?/ }"
        a?b?c

bash-2.05b output:

        $ echo ${a//\\?/ }
        a b c
        $ echo "${a//\\?/ }"
        a b c

now in bash-3 I have to remove one backslash:

        $ echo ${a//\?/ }
        a b c
        $ echo "${a//\?/ }"
        a b c
        

but this new sequence donesn't work in bash-2,
this only gives 5 spaces:

        $ echo x${a//\?/ }y
        x     y
        $ echo x"${a//\?/ }"y
        x     y



is this a bug or feature of bash-3 ?

how to I replace all '?' by ' ' in a shell variable
in a _portable_ way which works both in bash-2 and bash-3 ???



Repeat-By:
        see above

Fix:
        - 
        


thanks for any hint/fix !


Harald Koenig
-- 
"I hope to die                                      ___       _____
before I *have* to use Microsoft Word.",           0--,|    /OOOOOOO\
Donald E. Knuth, 02-Oct-2001 in Tuebingen.        <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig                                          \/\/\/\/\/\/\/\/\/
science+computing ag                                    //  /     \\  \
address@hidden                            ^^^^^       ^^^^^




reply via email to

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