﻿#!/usr/bin/perl -w
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);


# mpdl-workflow-settings.pl
# 2010-06-28
# Wolfgang Schmidle


# default-Einstellungen einlesen

my $defaultSettings = $ENV{'ECHO_SCRIPTS_DIR'} . "/share/mpdl-workflow-settings.txt";

@ARGV = ( "$defaultSettings" );

my $settings = "";
my %abbr = ();

while (<>) {
    chomp;
    s!#.*$!!; # remove comments
    s! +$!!;
    next if m!^$!;

    if (m!^([^ ]+) *= *([^ ]+)!) { 
        my $name = $1;
        my $def = $2;
        $def =~ s!{([^}]+)}!$abbr{$1}!g;
        $def = $ENV{'ECHO_SCRIPTS_DIR'} . $def;
        if ($name eq "defaultParameters") { 
            push @ARGV, $def;
            next;
        }

        $settings .= " $name=$def "; 
        $abbr{$name} = $def; 
    }
}

print "$settings\n";


# TO DO:
# String übergeben wie "unknown", und das Skript wertet dann speziell alle Paramter aus,
# die mit "unknown." anfangen?
