Change shell variable resolution order

This commit is contained in:
Tom Eastep 2010-11-07 13:28:03 -08:00
parent 1e6b7c8130
commit 8a9aaff4e8
3 changed files with 16 additions and 13 deletions

View File

@ -1858,16 +1858,19 @@ sub read_a_line(;$) {
my $count = 0;
#
# Expand Shell Variables using %params
# Expand Shell Variables using %params and %ENV
#
# $1 $2 $3 - $4
while ( $currentline =~ m( ^(.*?) \$({)? ([a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
unless ( exists $params{$3} ) {
$params{$3} = $ENV{$3} if exists $ENV{$3};
}
my $val = $params{$3};
$params{$3} = $ENV{$3} if exists $ENV{$3};
unless ( defined $val ) {
fatal_error "Undefined shell variable (\$$3)" unless exists $params{$3};
fatal_error "Undefined shell variable (\$$3)" unless exists $params{$3} || exists $ENV{$3};
$val = '';
}
@ -2882,9 +2885,8 @@ sub unsupported_yes_no_warning( $ ) {
# Process the params file
#
sub get_params() {
my $fn = find_file 'params';
if ( my $fn = find_file 'params' ) {
if ( $fn ) {
progress_message2 "Processing $fn ...";
my @params = `$globals{SHAREDIRPL}/getparams $fn`;

View File

@ -24,7 +24,7 @@
exported=$(env | sed 's/=.*//');
#
# Sigh -- POSIX shells don't support 'typeset' or 'declare'
# Sigh -- POSIX shells don't support 'typeset +x' or 'declare +x'
#
for v in $exported; do

View File

@ -30,13 +30,14 @@ VI. PROBLEMS CORRECTED AND NEW FEATURES IN PRIOR RELEASES
1) Previously, /usr/share/shorewall/compiler.pl expected the contents
of the params file to be passed in the environment. Now, the
compiler invokes the shell program /usr/share/shorewall/getparams
to process the file and to pass the (variable,value) pairs back to
the compiler.
compiler invokes a small shell program
(/usr/share/shorewall/getparams) to process the file and to pass
the (variable,value) pairs back to the compiler.
In this new implementation, the contents of the environment of the
program that launches /usr/share/shorewall/compiler.pl overrides
the contents of /etc/shorewall/params.
Shell variable expansion uses the value from the params file if the
parameter was set in that file. Otherwise the current environment
is used. If the variable does not appear in either place, an error
message is generated.
----------------------------------------------------------------------------
I V. R E L E A S E 4 . 4 H I G H L I G H T S