Skip to content

Commit ece798a

Browse files
authored
scr_param.pm: escape braces in regex (#105)
1 parent 8da72a0 commit ece798a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

scripts/common/scr_param.pm.in

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,18 @@ sub read_config_file
114114
exit 1;
115115
}
116116

117-
# my $value = shift @parts;
118-
my $raw_value = shift @parts;
119-
my $value = '';
120-
my @value_parts = split(/(\$\w+)|(\${\w+})/, $raw_value);
121-
foreach my $seg (@value_parts)
122-
{
123-
next if (not defined($seg));
124-
$seg = ($ENV{$1} || '') if ($seg =~ m/\${?(\w+)}?/);
125-
$value .= $seg;
126-
}
117+
# expand any embedded environment variable names as in
118+
# key=$ENVVAR or key=/home/${USER}/${SLURM_JOBID}
119+
# replaces variable with its value from the environment
120+
my $value = '';
121+
my $raw_value = shift @parts;
122+
my @value_parts = split(/(\$\w+)|(\$\{\w+\})/, $raw_value);
123+
foreach my $seg (@value_parts)
124+
{
125+
next if (not defined($seg));
126+
$seg = ($ENV{$1} || '') if ($seg =~ m/\$\{?(\w+)\}?/);
127+
$value .= $seg;
128+
}
127129

128130
# record the key value pair in the hash
129131
if (defined $master_key) {

0 commit comments

Comments
 (0)