I have this at the very top of my .bashrc, before the return for non-interactive shells
FOO="BAR"; export FOO
echo "HELLO WORLD"
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
I have a script test.sh in my homedirectory with this:
#!/bin/bash
echo "A"
echo $FOO
echo "B"
I execute test.sh. The output:
A
B
2 Questions:
- Why don't I see the value of $FOO?
- Why don't I see the "HELLO WORLD"?
edit: I thought the script with #!/bin/bash triggers a subshell which will call the .bashrc again, am I that wrong?
edit: Even If I do call the script from another host I won't see any values. Not even then , the .bashrc will be executed???
ssh remotehost "/home/username/test.sh"