bash

Set bash variables once before using across multiple scripts


Let's say I have the following two commands:

A=1 B=2 C=3 run-app1.py
A=1 B=2 C=3 run-app2.py

I'd love to dry this out so I only need to update the variables in one place (and not risk them getting out of sync). Something like:

VALUES = get-values.sh

VALUES run-app1.py
VALUES run-app2.py

How can I do this?


Solution

  • Export all the variables then run the scripts:

    export A=1 B=2 C=3
    run-app1.py
    run-app2.py