Re: command substitution and word splitting

2008-12-13 Thread Stephane Chazelas
On Sat, Dec 13, 2008 at 09:30:27AM +0100, Andreas Schwab wrote:
> "S. Sevki Dincer"  writes:
> 
> > i want to start building a project with ./configure --prefix=... $(myflags)
> > where myflags is an executable text file on my path. myflags has the
> > following in it:
> > printf 'CFLAGS="-O2 -fomit-frame-pointer" '
> > printf 'LDFLAGS="-Wl,-O2"'
> > now, when i do that ./configure complains for not recognizing
> > -fomit-frame-pointer option, and actually word splitting of bash ruins
> > what i wanna do. i want the word splitting of a command substitution
> > "to be careful about the quotes in the resulting expansion". is that
> > possible?
> 
> Use eval.
> 
> eval ./configure --prefix=... $(myflags)
[...]

eval "./configure --prefix=... $(myflags)"

as you don't want word splitting nor filename generation in this
case.

You could also have done:

printf 'CFLAGS=-O2 -fomit-frame-pointer|'
printf 'LDFLAGS=-Wl,-O2'

and then:

IFS='|'
set -f
./configure --prefix=... $(myflags)

Or:

cat << EOF
CFLAGS=-O2 -fomit-frame-pointer
LDFLAGS=-Wl,-O2
EOF

and then:

IFS='
'
set -f
./configure --prefix=... $(myflags)

-- 
Stéphane




Re: echo $s{2,3}

2008-12-13 Thread Bernd Eggink

jida...@jidanni.org schrieb:

What happened to 2,3? Poof, gone.
$ s=a; echo $s{ $s{} $s} $s{1} $s{2,3} ${s}{4,5}
a{ a{} a} a{1} a4 a5


As the manual says, brace expansion is performed before any other 
expansions. So $s{2,3} expands to $s2 $s3, and that expands to nothing 
if neither s2 nor s3 are set.


Regards,
Bernd

--
Bernd Eggink
http://sudrala.de




echo $s{2,3}

2008-12-13 Thread jidanni
What happened to 2,3? Poof, gone.
$ s=a; echo $s{ $s{} $s} $s{1} $s{2,3} ${s}{4,5}
a{ a{} a} a{1} a4 a5




Re: command substitution and word splitting

2008-12-13 Thread Andreas Schwab
"S. Sevki Dincer"  writes:

> i want to start building a project with ./configure --prefix=... $(myflags)
> where myflags is an executable text file on my path. myflags has the
> following in it:
> printf 'CFLAGS="-O2 -fomit-frame-pointer" '
> printf 'LDFLAGS="-Wl,-O2"'
> now, when i do that ./configure complains for not recognizing
> -fomit-frame-pointer option, and actually word splitting of bash ruins
> what i wanna do. i want the word splitting of a command substitution
> "to be careful about the quotes in the resulting expansion". is that
> possible?

Use eval.

eval ./configure --prefix=... $(myflags)

Andreas.

-- 
Andreas Schwab, SuSE Labs, sch...@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."