obsolete function remains in bash enviroment

53 Views Asked by At

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?

1

There are 1 best solutions below

2
Brian Agnew On BEST ANSWER

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