Q:

desktop launcher is not successfully setting environment

I created a MATLAB desktop launcher. It executes matlab -desktop fine, but my configuration requires that some environment variables are set first. When I open a terminal, these variables are set by /etc/bash.bashrc, which sources a script for setting up the work environment.
I created a script to try to work around this:
#!/bin/bash
/path/to/environment/setup/script.sh
matlab -desktop

I set my launcher to execute this script. It launches MATLAB successfully, but the variables are still not set correctly. What gives?

A:

If you want to export variables into the script's environment from an external script, then you need to source the script.
#!/bin/bash
. /path/to/environment/setup/script.sh
matlab -desktop

