Search code examples
bashshellenvironment-variablesbash-function

obsolete function remains in bash enviroment


If I define a function in a bash script, e.g., envsetup.sh

function blabla() 
{
  echo "blabla"
}

then i source it by

. envsetup.sh

There is blabla function in my environment to use. However, if I remove this function and source it again, the blabla function is still there.

Why is it not deleted?


Solution

  • It's still the same Bash process, and running your envsetup.sh simply amends that process. If you invoked a new Bash shell and ran your script there, then your function wouldn't exist.

    You can remove that function in your shell script thought. You can do this via:

    unset -f blabla