My .bashrc
file exports a function called lookup
:
lookup() {
grep -r -ne "$1" * | grep -v "TAGS:" | grep -v "tags:"
}
export -f lookup
I can use that function in a shell. But if I put it in a script like this:
#!/bin/bash
lookup "foo"
and run the script then bash reports "command not found" for lookup
. This used to work some time ago. I strongly suspect this is stopped working after a security update of bash on my system (possibly related to shellshock/bashdoor?) My bash version is 4.1.10(1) on openSUSE 11.4
Best Answer
Check http://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files
Specifically, none of the ~/.bashrc, ~/.profile, ~/.bash_profile are NOT sourced. ~/.bashrc is only invoked if the shell is an interactive shell.
You have a couple of options:
source your .bashrc explicitly
start bash with the interactive flag
set the BASH_ENV variable when you start your script: