Bug#655712: ITP: template -- environment variable expander | simple template tool
Michael Stummvoll <michael@stummi.org> writes:
> On 13.01.2012 15:05, Steve McIntyre wrote:
>> * I don't really see how this program is more useful than a very
>> simple shell (or perl, or python, or ...) loop to do the same
>> thing.
> I looked a while for a simple shell loop which does exactly this. But
> could'nt find one, so I wrote this tool.
> All bash-scripts I found used some tricky eval-hacks, which i wanted
> to avoid.
I would suggest using perl, which is an essential package anyway, and
doing an env-var substitution on its stdin is as simple as this:
#! /usr/bin/perl -wnp
s/(\$\{([^\}]+)\})/$ENV{$2} || $1/eg;
A separate package for this is way overkill.
(By the way, you can abuse /usr/share/dh-exec/dh-exec-subst-env, which
does just that, and is part of the dh-exec package, if you don't want to
put it in a script in ~/bin or something. ;)
--
|8]
Reply to: