Re: command substitution and word splitting
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: command substitution and word splitting
"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."
command substitution and word splitting
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-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 Gauss 2.6.24-22-generic #1 SMP Mon Nov 24 19:35:06 UTC 2008 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 3.2 Patch Level: 39 Release Status: release Description: 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? note: i have xubuntu 8.04 amd64 desktop, on a core2 dell laptop. Fix: something like $(command@) can be added to bash, retaining old functionality. the new one will warn (somehow) word splitting to be careful about possible quotes in the resulting expansion of the command substitution.