bash help setting variables

Bruno Wolff III bruno at wolff.to
Sat Oct 17 19:14:20 UTC 2009


On Sat, Oct 17, 2009 at 11:58:12 -0700,
  Donald Russell <russell.don at gmail.com> wrote:
> I'm trying to write a bash script which makes an inquiry to an http
> service that replies with a series of keyword=value plain text data,
> one pair per line.
> I want to extract only a few of the lines, and make variables of them
> available to rest of my bash script.

I wrote something to pull some values out of xml data returned by svn that
has a few similarites to what you were doing.

One key thing was handling multiple values returned by one command. I ended
up using arrays for this. They need to be escaped more carefully, but it
seemed better than running the command one for each returned value.

I use the following to get a couple of values:
REV=(`svn info -r $1 --xml --incremental $COLOSSUS | xsltproc colossus-rev.xsl -
`)

And then I use them like this:
svn export -q -r ${REV[1]} $COLOSSUS colossus-${BNAME}-${REV[0]}-${REV[1]}

This is from the colossus srpm and you can look at it if you want to see
more of the example.




More information about the fedora-list mailing list