Reputation: 667
I use variables in my script and run the script in the following way . ./test.sh
. And as it should be, after the script finishes, all the set variables remain in the shell; I know that at the end of the script one can add unset variable variable2
. But what if there are a lot of variables, is there a way/command to unset all set variables in the script at once at the end?
Upvotes: 0
Views: 982
Reputation: 361977
Do you need to run it with .
? Normally one does that in order to have variable assignments persist afterward.
If you run the script with just ./test.sh
then it'll run as a child process with a separate environment from the parent shell. Variable assignments in the child will not affect the parent, and they'll be lost when the child exits.
Upvotes: 1