Skip to content

Instantly share code, notes, and snippets.

@stevekuznetsov
Last active May 9, 2016 15:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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