mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-27 18:13:13 +01:00
Change shell variable resolution order
This commit is contained in:
parent
1e6b7c8130
commit
8a9aaff4e8
@ -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`;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user