Skip to content

Commit

Permalink
scr_param.pm: escape braces in regex (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
adammoody authored Nov 3, 2017
1 parent 8da72a0 commit ece798a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions scripts/common/scr_param.pm.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,18 @@ sub read_config_file
exit 1;
}

# my $value = shift @parts;
my $raw_value = shift @parts;
my $value = '';
my @value_parts = split(/(\$\w+)|(\${\w+})/, $raw_value);
foreach my $seg (@value_parts)
{
next if (not defined($seg));
$seg = ($ENV{$1} || '') if ($seg =~ m/\${?(\w+)}?/);
$value .= $seg;
}
# expand any embedded environment variable names as in
# key=$ENVVAR or key=/home/${USER}/${SLURM_JOBID}
# replaces variable with its value from the environment
my $value = '';
my $raw_value = shift @parts;
my @value_parts = split(/(\$\w+)|(\$\{\w+\})/, $raw_value);
foreach my $seg (@value_parts)
{
next if (not defined($seg));
$seg = ($ENV{$1} || '') if ($seg =~ m/\$\{?(\w+)\}?/);
$value .= $seg;
}

# record the key value pair in the hash
if (defined $master_key) {
Expand Down

0 comments on commit ece798a

Please sign in to comment.