There's several centos linux boxes at my workplace.
I've been tasked with creating some form of environment variable tool for them.
The idea is the user runs the tool, with the argument of their project (and perhaps their pythonpath 'mode'), press enter and a) a new variable called
"PROJ" is made and b) their
PYTHONPATH has a new folder appended. The scope of these variables only lasts as long as they have that terminal session open.
I've seen this at other places I've worked at. But I never dug deep enough to understand it's working, which I'm kicking myself now!
I'm guessing it's a bash script that exports the variable name to the path given. Python does export environment variables, it but it doesn't remain - it's like the export is only applied to child processes of the python script, so when the script ends, the variables end too. This is why I've come to the conclusion it's a bash script.
If so, what's the best way to distribute this tool, so all boxes have the script, preferably aliased so the user isn't typing
Secondly, what's the best way of checking if arguments are valid? I was thinking of a json file with the correct project codes in them.
Lastly, can I have a mixture of flagged and non-flagged arguments? eg, the user would type something like
<tool_name> <project_title> -f where -f would be an additional, optional feature? Should I roll it out to each user's ~/.bashrc?
If there are any examples of what I'm looking for, I'd be incredibly grateful to be pointed in the right direction...