Skip to content

Instantly share code, notes, and snippets.

@dokipen
Created October 28, 2016 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dokipen/fafe360656dcef1ad0a68cce019d2c27 to your computer and use it in GitHub Desktop.
Save dokipen/fafe360656dcef1ad0a68cce019d2c27 to your computer and use it in GitHub Desktop.
Why don't fields set in the loop propagate out of the loop?
declare -A testthis
testthis[hello]="world"
echo "keys: ${!testthis[@]}"
printf "a\nb\nc\nd\ne\nf\n" | while read key && read value; do
testthis[$key]="${value}"
echo "keys: ${!testthis[@]}"
done
echo "keys: ${!testthis[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment