bug-bash
[Top][All Lists]
Advanced

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

Re: strange pattern replacing in parameter expansion


From: Chet Ramey
Subject: Re: strange pattern replacing in parameter expansion
Date: Wed, 16 Mar 2005 11:50:14 -0500
User-agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)

Bernard VAUQUELIN wrote:

Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: i586-mandrake-linux-gnu-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-mandrake-linux-gnu' -DCONF_VENDOR='mandrake' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro uname output: Linux philtre.labri.fr 2.6.3-4mdk #1 Tue Mar 2 07:26:13 CET 2004 i686 unknown unknown GNU/Linux
Machine Type: i586-mandrake-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
       strange pattern replacing in parameter expansion

               x="*.c" ; echo $x ; echo ${x//.c/.o}
       gives
               toto.c titi.c
               *.o

I'll bet there aren't actually any .o files in that directory.  In
this example, you're relying on filename generation to produce the
corresponding .o names.  If no files matching "*.o" exist, the
pattern is left unchanged.

       which seems strange to me,
       but
               x=`echo *.c` ; echo $x ; echo ${x//.c/.o}
       gives
               toto.c titi.c
               toto.o titi.o
       as expected

In this example, you're not relying on filename generation to produce
the .o names, since $x is `toto.c titi.c' instead of `*.c'.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
                                                Live...Laugh...Love
Chet Ramey, ITS, CWRU    chet@case.edu    http://tiswww.tis.cwru.edu/~chet/




reply via email to

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