Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unset bash function variable with non-standard name

I may have this function in a bash script that gets sourced to the shell

function suman{
     echo "using suman function"
}

if I call

unset suman

things seem to work as expected

however if I have this as my function:

function suman-inspect {
     echo "using suman-inspect function"
}

then if I call

unset suman-inspect

or

unset "suman-inspect"

I get this message:

bash: unset: `suman-inspect': not a valid identifier

How can unset this variable as is?

like image 204
Alexander Mills Avatar asked Nov 25 '16 22:11

Alexander Mills


1 Answers

After some more research, it appears that

unset -f "suman-inspect"

will work. This is surprising because unset suman did work, and did successfully unset the suman function (as far as I could tell).

like image 82
Alexander Mills Avatar answered Sep 30 '22 18:09

Alexander Mills