I have several individual bash scripts. They do different things, and are large (70-100 lines each). Thus I have kept them in separate files. But they are all related to a central problem and hence share several constant values in common.
So, for simplicity, I have ten constant variables, some are strings, some are numbers, while two are arrays, all of which need to be available throughout ten different bash scripts. How do I achieve this?
Note that while there is a central
main.sh which can call these individual bash scripts, this won't always be the case. They can also be called directly from the command line (
./script1.sh). Even in that case the variables should be made available to the scripts.
The only way I thought of was that to code in
dev/script1.temp.sh files, and every time I need to run any file, I run a
build.sh bash script that simply replaced (via
grep) all occurrences of a particular constant (
$CONSTANT) throughout the file to produce