Closed nkakouros closed 6 years ago
I'm not sure. On the one hand, I'm inclined to wonder why anyone would want to encapsulate sourcing the framework in a function, other than perhaps for documentation reasons or for bundling together the import of multiple frameworks. (Possible workaround: create a libs.sh
that sources all the frameworks, then source that file in one line in your main script.)
On the other, I was originally strict about limiting the scope of framework-wide variables (e.g. using declare -r
), but over time started relaxing the strict scoping of such variables when the restrictions started causing problems in newer modules.
By default, I'm not inclined to change the current declarations. But I'm open to arguments presenting a compelling use case, since I don't think the changes would be that difficult or dangerous (especially given how thoroughly everything's tested).
Maybe declaring all these variables as global is just too messy. The workaround you suggest allows for sufficient tidying up of the code. So, issue resolved for me!
Due diligence
Framework, Bash, and operating system version information
Description
If the
go-core.bash
file is sourced in a function and not in the main body of the intro script of a project, then many variables are not set properly. For instance:will fail since variables like
_GO_USE_MODULES
and_GO_CORE_DIR
will be undefined.In this case, the solution is easy, just declare the missing variables as global, not only as exported.
Should this be considered a use case go-script-bash should cater for?