Skip to content

fix: avoid variable scope leaking for clone_repo function, declare lo… - #48

Merged
kambala-decapitator merged 2 commits into
vcmi:mainfrom
art6f:fix/mac-arm-build
Sep 7, 2026
Merged

kambala-decapitator merged 2 commits into
vcmi:mainfrom
art6f:fix/mac-arm-build

Conversation

@art6f

@art6f art6f commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

On MacOS arm64 (tested on MacOS v25.6.0) some variable are leaking the scope of the function and keeping being set, which breaks the build.

Despite the following check is clearly failing on an empty $sparseCheckoutPaths

[ ${#sparseCheckoutPaths[@]} -eq 0 ] || hasSparseCheckout=1
#    ^ --- is empty, hence [@] is zero           ^ --- must not be set

the variable hasSparseCheckout remains set from a previous call (see the test log below).

The change is simple:

  • explicitly initialise the hasSparseCheckout as 0
  • force all the local function arguments as the local variables
Test log for clone_repo() calls
Started Sun Sep  6 19:46:39 CEST 2026
Call clone_repo
	repoUrl='https://github.com/kambala-decapitator/conan-system-libs'
	repoPath='/var/folders/rj/qbg4m0qx04v_p2qjd14qpy1w0000gn/T//conan-system-libs'
	branch='main'
	sparseCheckoutPaths[@]='0'

	Variable (pre-check): hasSparseCheckout=''
	Variable (post-check): hasSparseCheckout=''

Call clone_repo
	repoUrl='https://github.com/conan-io/conan-center-index'
	repoPath='/var/folders/rj/qbg4m0qx04v_p2qjd14qpy1w0000gn/T//conan-center-index'
	branch='master'
	sparseCheckoutPaths[@]='3'

	Variable (pre-check): hasSparseCheckout=''
	Variable (post-check): hasSparseCheckout='1'

Call clone_repo
	repoUrl='https://github.com/kambala-decapitator/conan-center-index'
	repoPath='/var/folders/rj/qbg4m0qx04v_p2qjd14qpy1w0000gn/T//cci-fork'
	branch='vcmi'
	sparseCheckoutPaths[@]='1'

	Variable (pre-check): hasSparseCheckout='1'
	Variable (post-check): hasSparseCheckout='1'

Call clone_repo
	repoUrl='https://github.com/kambala-decapitator/conan-luajit'
	repoPath='/var/folders/rj/qbg4m0qx04v_p2qjd14qpy1w0000gn/T//luajit'
	branch='master'
	sparseCheckoutPaths[@]='0'

	Variable (pre-check): hasSparseCheckout='1'
	Variable (post-check): hasSparseCheckout='1'

Ended Sun Sep  6 19:46:56 CEST 2026

@kambala-decapitator
kambala-decapitator merged commit 3d4a05d into vcmi:main Sep 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants