Denis
Denis

Reputation: 1534

can't change DYLD_LIBRARY_PATH inside sh script

I have a shell script with something like

#!/bin/bash
export DYLD_LIBRARY_PATH=/path/to/:$DYLD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH

When i execute it, it shows nicely the updated 'DYLD_LIBRARY_PATH'. However, when i try to check what's in there after i run the script via

echo $DYLD_LIBRARY_PATH

from the command line, i see no changes what so ever.

p/s/ I run OS-X 10.8

Upvotes: 1

Views: 376

Answers (1)

trojanfoe
trojanfoe

Reputation: 122458

You need to source the script:

$ . ./my_script.sh

So that setting environment variables affects the current shell. You are setting it in a sub-shell only.

Upvotes: 1

Related Questions