What Is The Source Command And How I Use It In Bash
1. NOTES
Feb 18, 2022
source
is a bash shell built-in command that executes the content of the file passed as an argument, in the current shell. It has a synonym in.
(period).
Syntax
. filename [arguments]
source filename [arguments]
2. USE: CONFIG FILE EXECUTION
- I have many config files (per environment)
- On top of that, there is a single script that accepts these config files; the script is a wrapper of another python script that does the job
- The config file has lines such as
db_name="foo"
db_port="5439"
...
...
- I
source
(execute the contents of) the config file within the wrapper to assign the bindings within the wrapper's runtime
env = $1
config = ${root_dir}/${env}/config.txt
source "${config}"
- Wrapper passes these bindings into another python script