Source command don't export environment variable

Viewed 25

I have a shell file, test.sh

source /home/sea/.bashrc; echo $VAR; sleep 3

.bashrc

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

...

export VAR=abc

And execute gnome-terminal -- bash -xc "source test.sh" in a terminal

It outputs nothing in the end, the problem is resolved

+ source test.sh
++ source /home/sea/.bashrc
+++ case $- in
+++ return
++ echo

++ sleep 3
0 Answers
Related