To avoid sourcing this twice and getting globals mixed up,
particularly when using multiple plugins, add a "header guard" that
ensures we only source it once.
In general I don't think functions/functions-common have been written
or considered to be idempotent. I don't think going down that path is
going to be a long-term solution as it's easy to break.
Change-Id: Idca49eb996d2b7ff3779ec27ed672a2da7852590
Closes-Bug: #1469178
... | ... |
@@ -10,6 +10,10 @@ |
10 | 10 |
# - ``GLANCE_HOSTPORT`` |
11 | 11 |
# |
12 | 12 |
|
13 |
+# ensure we don't re-source this in the same environment |
|
14 |
+[[ -z "$_DEVSTACK_FUNCTIONS" ]] || return 0 |
|
15 |
+declare -r _DEVSTACK_FUNCTIONS=1 |
|
16 |
+ |
|
13 | 17 |
# Include the common functions |
14 | 18 |
FUNC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd) |
15 | 19 |
source ${FUNC_DIR}/functions-common |
... | ... |
@@ -36,6 +36,10 @@ |
36 | 36 |
XTRACE=$(set +o | grep xtrace) |
37 | 37 |
set +o xtrace |
38 | 38 |
|
39 |
+# ensure we don't re-source this in the same environment |
|
40 |
+[[ -z "$_DEVSTACK_FUNCTIONS_COMMON" ]] || return 0 |
|
41 |
+declare -r _DEVSTACK_FUNCTIONS_COMMON=1 |
|
42 |
+ |
|
39 | 43 |
# Global Config Variables |
40 | 44 |
declare -A GITREPO |
41 | 45 |
declare -A GITBRANCH |