Skip to content

Commit 4ffb454

Browse files
committed
Add header guard to functions/functions-common
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
1 parent 04c0f0b commit 4ffb454

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

functions

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
# - ``GLANCE_HOSTPORT``
1111
#
1212

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+
1317
# Include the common functions
1418
FUNC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
1519
source ${FUNC_DIR}/functions-common

functions-common

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
XTRACE=$(set +o | grep xtrace)
3737
set +o xtrace
3838

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+
3943
# Global Config Variables
4044
declare -A GITREPO
4145
declare -A GITBRANCH

0 commit comments

Comments
 (0)