[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sourcing array declarations from a function
From: |
Marco Ippolito |
Subject: |
Sourcing array declarations from a function |
Date: |
Thu, 26 Nov 2020 17:17:03 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
I would not expect this asymmetry of visibility, what explains it?
#! /usr/bin/env bash
cat > /tmp/file.bash << 'EOF'
parameter=foo
declare -A bar=([baz]=quux)
EOF
f() {
source /tmp/file.bash
}
f
echo "parameter: $parameter"
echo "bar's values: ${bar[@]}"
source /tmp/file.bash
echo "parameter: $parameter"
echo "bar's values: ${bar[@]}"
=== >
parameter: foo
bar's values:
parameter: foo
bar's values: quux
--
Marco Ippolito
maroloccio@gmail.com
- Sourcing array declarations from a function,
Marco Ippolito <=