[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parameter expansion oddity
From: |
Chet Ramey |
Subject: |
Re: Parameter expansion oddity |
Date: |
Tue, 08 Jul 2003 09:48:10 -0400 |
> Configuration Information [Automatically generated, do not change]:
> Machine: i386
> OS: linux-gnu
> Compiler: i386-redhat-linux-gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
> -DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
> -D_GNU_SOURCE -O2 -g -pipe -march=i386 -mcpu=i686
> uname output: Linux meme.surrey.redhat.com 2.4.20-13.9 #1 Mon May 12 10:55:37
> EDT 2003 i686 i686 i386 GNU/Linux
> Machine Type: i386-redhat-linux-gnu
>
> Bash Version: 2.05b
> Patch Level: 0
> Release Status: release
>
> Description:
> ${VAR:+WORD} may be replaced by the expansion of WORD. But there
> seems to be no way of creating double quotes in this expansion, since
> both quote removal and escaping behave oddly.
Are you wedded to using here documents? Remember that here-docs are expanded
as if the contents occur within double quotes, but that double quotes within
the document aren't treated specially.
> Repeat-By:
> Trying to get output: "bar"
echo "${FOO:+\"$FOO\"}"
echo ${FOO:+\"$FOO\"}
echo ${FOO:+'"'$FOO'"'}
all echo `"bar"'.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Chet Ramey, ITS, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/