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

Re: Bug#655712: ITP: template -- environment variable expander | simple template tool



On Fri, 13 Jan 2012 16:11:50 +0100
Michael Stummvoll <michael@stummi.org> wrote:

> On 13.01.2012 16:00, Neil Williams wrote:
> > The point about sed is that sed can substitute whatever you like into
> > whatever you like - printenv with grep and sed gets the value, then
> > another grep for the lines that matter and pass those lines to sed. It
> > really isn't hard.
> ok, please can you give me an example sed-command which replaces ${.*} 
> with the according environment-variables? 

Just join the dots of the sample commands already included in this bug
report (which doesn't deserve this much of my time TBH). You may need a
few judicious uses of 'eval' to expand the variables but by that stage,
you might as well just do the entire job in perl, python or whatever
else. Just not in shell.

> I couldn't find this yet and 
> nobody could point me to it yet.

What's the quote... if I wanted to do what you're describing I wouldn't
start where you are currently... I'd have done it in perl and many
others would choose python. Just don't expect shell to do this
usefully. It's much quicker in a.n.other language.

> The only way to do this I seeing atm is 
> to iterate through $(printenv) and replace all listed 
> environment-variables in the stream using sed. But this way seams very 
> "bloat" to me.

Then don't use a shell interpreter to do the job, write the entire
thing in a sensible, fast, language - not just the parser.

Any perl or python or C loop would do exactly the same - scrobble
together all the desired variables out of the environment into an array
or hash, then load the file and substitute the value wherever the key of
the hash exists in what you've read from the file.

> And when i write such a tool for myself, why does it matter if i do this 
> with python, perl, ruby, php, c or something else?

It only matters because you gave the reason for the package as needing
to do this in shell and if you are going to write the parser in
something else, why bother doing the rest of the work in shell? Any
other language wouldn't need this kind of support and would do the
entire job a lot faster than a combination of the tool and shell.

Please do write it for yourself, just don't expect to find a use for it
in Debian.

If you can't work it out, I'm sorry but I don't have the time to walk
you through it. The package proposed is still too trivial and pointless
to be useful in Debian IMHO.

-- 


Neil Williams
=============
http://www.linux.codehelp.co.uk/

Attachment: pgpXtfS0OiXfz.pgp
Description: PGP signature


Reply to: