Skip to content

Instantly share code, notes, and snippets.

@stevekuznetsov
Last active May 9, 2016
Embed
What would you like to do?
readonly source failures
#!/bin/bash
function init() {
source readonly.sh
echo "inside init: ${MY_VAR[*]}" # success
}
init
echo "after init: ${MY_VAR[*]}" # failure
$ test.sh
inside init: some-text
init.sh: line 9: MY_VAR[*]: unbound variable
#!/bin/bash
readonly MY_VAR=(
"some-text"
)
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
source init.sh
echo "after source: ${MY_VAR[*]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment