]> mj.ucw.cz Git - libucw.git/commitdiff
Build: Let genconf expand variables recursively.
authorMartin Mares <mj@ucw.cz>
Sun, 27 Jul 2008 15:11:36 +0000 (17:11 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 27 Jul 2008 15:27:50 +0000 (17:27 +0200)
This is useful for example when filling in installation paths in configuration
files.

build/genconf

index eaf2d1c727155632aca5700c29fcd0cda82e7bcc..30e8896c3a58901e5085880ed6628d0e5600665d 100755 (executable)
@@ -66,10 +66,13 @@ while (<IN>) {
                        die "Piped command '$cmd' failed" if $?;
                        print OUT `$1`;
                } else {
-                       sub repl ($) {
+                       sub repl($);
+                       sub repl($) {
                                my $v = shift @_;
                                exists $vars{$v} or die "Cannot substitute $v: variable not set";
-                               return $vars{$v};
+                               my $x = $vars{$v};
+                               while ($x =~ s/\$\((\w+)\)/repl($1)/ge) { }
+                               return $x;
                        }
                        s/@(\w+)@/repl($1)/ge;
                        print OUT;