0

Calling export MYVAR=/path/to/whatever from .bashrc obviously works for bash but not for the sh shell. Unfortunately, the Matlab launcher seems hell-bent on using sh and not bash. As such, the simplest way to export an environment variable such that it is accessible from Matlab would be to export said variable to sh.

How can I persistently export an environment variable to sh?

1 Answers1

1

Perform the following steps in the current shell (tested with zsh and bash), not in dash:

  1. Open your .profile:

    nano ~/.profile
    
  2. Add this line

    ENV=$HOME/.dashrc; export ENV
    
  3. Open .dashrc

    nano ~/.dashrc
    
  4. Add this line:

    export MYVAR=/path/to/whatever
    
  5. Finally reload .profile

    . ~/.profile
    

    or log out and then log in again.

Now start dash with:

  • sh

    or

  • dash

and type

$ echo $MYVAR
/path/to/whatever
Fabby
  • 34,259
A.B.
  • 90,397