Keep vars environment after shell script ends
This is not possible by running the script. The script creates its own subordinate shell, which is lost when the script terminates.
To save export
what your script may have, you can call them like this to add them to your current environment:
. myScript.sh
Note the space between the .
and sections myScript.sh
.
source to share
Environment variables represent an environment that is private to each process. The shell passes the COPY of the exported variables into it as its environment, but there is no way to return their environment to parents or other processes other than their children. You can print these variables and load them into the parent. Or, as mentioned, you can run the script in the current shell using "source script" or ".w371>" (and you may need. / Script if not in your TRACK). Some instruments print their vars, and the shell can load them using reverse ticks, for example ssh-agent
. This way, any ssh-agent prints will run as a command. If it prints something like "VAR1 = VAL; VAR2 = VAL2" which might do what you want.
source to share