env variables with spaces

C M Reinehr cmr
Wed Feb 28 07:58:34 PST 2007


On Wednesday 28 February 2007 09:35, Net Llama! wrote:
> On Wed, 28 Feb 2007, C M Reinehr wrote:
> > On Tuesday 27 February 2007 18:22, Net Llama! wrote:
> >> I'm running into an annoying problem.  I'm taking the output from 'env'
> >> and dumping it to a file (/tmp/env.out), and then running 'source
> >> /tmp/env.out'.  The problem is that some of the variables in env output
> >> have values assigned to them with spaces, such as:
> >> FOO=release debug
> >>
> >> When source hits this, it gets confused and assumes that the ' debug'
> >> portion is something separate from the value of FOO, and barfs:
> >> bash: release: command not found
> >>
> >> Anyone have any suggestions how to get around this?  thanks
> >
> > Perhaps you could redefine the IFS environment variable just to <newline>
> > instead of the default <space><tab><newline> before running source.
>
> Actually, Kurt suggested this to me on the irc channel, but I couldn't get
> it to work at all.  At this point, I think I'm going to give Bill's sed
> solution a try, as it looks the most promising.  One thing that I failed
> to mention initially is that I need this to also work under cygwin, and
> there's no pythong there (as far as I can tell), so sed would be the best
> cross platform solution.

That's actually kind of funny. I've tried unsuccessfully to do this in the 
past and was hoping you would be able to show me how to do it. :-)

I have been able to something similar to this with awk (nawk). With awk it's 
quite easy to read in a line & parse it anyway you want. Then do what you 
need to do & write it back out.

Cheers!

cmr

-- 
Debian 'Etch' - Registered Linux User #241964
--------
"More laws, less justice." -- Marcus Tullius Ciceroca, 42 BC



More information about the Linux-users mailing list