You will want to make $a an array, e.g.:
a=(arg1 arg2)
a+=(arg3)
Then unpack properly: "${a[@]}"
Here's a pretty good guide:
http://mywiki.wooledge.org/BashGuide/Arrays
Cheers,
Dave
Hi folks,
I'm banging my head against how to properly pass a list of arguments in
a variable through to a command in bash where the list of arguments
itself has quoted values in it.
Here's a test case script:
$ cat odd-quoting.sh
#!/bin/bash
a='--debug --make-maker=--make-maker="INSTALLDIRS=vendor INSTALLMAN1DIR=none INSTALLMAN3DIR=none" --no-sign'
echo cpan2rpm $a
If I run that script with dash on Ubuntu it looks fine:
$ sh -x odd-quoting.sh
+ a=--debug --make-maker=--make-maker="INSTALLDIRS=vendor INSTALLMAN1DIR=none INSTALLMAN3DIR=none" --no-sign
+ echo cpan2rpm --debug --make-maker=--make-maker="INSTALLDIRS=vendor INSTALLMAN1DIR=none INSTALLMAN3DIR=none" --no-sign
[...]
But if I run it with bash on either Ubuntu or my actual target, RHEL6,
it gets it wrong:
$ bash -x odd-quoting.sh
+ a='--debug --make-maker=--make-maker="INSTALLDIRS=vendor INSTALLMAN1DIR=none INSTALLMAN3DIR=none" --no-sign'
+ echo cpan2rpm --debug '--make-maker=--make-maker="INSTALLDIRS=vendor' INSTALLMAN1DIR=none 'INSTALLMAN3DIR=none"' --no-sign
[...]
I get the same problem if I run bash from its /bin/sh symlink on RHEL6.
Any ideas what I'm missing here ?
cheers,
Chris
--
Chris Samuel : http://www.csamuel.org/ : Melbourne, VIC
_______________________________________________
luv-main mailing list
luv-main@luv.asn.au
http://lists.luv.asn.au/listinfo/luv-main