How do I unset or get rid of a bash function?
Problem
If you set or export an environment variable in bash, you can unset it. If you set an alias in bash, you can unalias it. But there doesn't seem to be an unfunction. Consider this (trivial) bash function, for example, set in a .bash_aliases file and read at shell initialization. How can I clear this function definition from my current shell? (Changing the initialization files or restarting the shell doesn't count.)
Error Output
function foo () { echo "bar" ; }Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How do I unset or get rid of a bash function?
The unset built-in command takes an option, , to delete functions: Form the unset entry in the bash manpage: If -f is specified, each name refers to a shell function, and the function definition is removed. Note: is only really necessary if a variable with the same name exists. If you do not also have a variable named , then will delete the function.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix