When you run your script like this:
./test.sh whatever
Bash runs another instance of shell which interprets command in your script. If you want to set variables in the current shell, you should use source
command, or dot (.
). In this case the commands in the script will be executed in the current shell directly.
source test.sh
or just
. test.sh