Will Dyson on Wed, 27 Nov 2002 06:04:20 -0500


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

[PLUG] Variable interpolation in bash


This has been bugging me for a while now. When I am writting a bash script, I often want to do something of the form:

	COMMAND_OPTIONS="-foo -bar --long-opt-whos-arg 'has spaces'"
	command $COMMAND_OPTIONS baz

What I want to happen is for the shell to eventually execute:

	command -foo -bar --long-opt-whos-arg 'has spaces' baz

But it doesn't. Instead, I get an error from command along the lines of "argument 'spaces' unrecognized", indicating that the shell has not passed 'has spaces' as a single argument to command.

Running the script with bash -x shows me this:

	+ COMMAND_OPTIONS=-foo -bar --long-opt-whos-arg 'has spaces'
	+ command -foo -bar --long-opt-whos-arg ''\''has' 'spaces'\''' baz

Any suggestions?

--
Will Dyson
"Back off man, I'm a scientist!" -Dr. Peter Venkman

_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug