After sourcing the following code my terminal is able to see __hey
function.
super_tools() {
case "$1" in
"hey")
__hey
;;
*)
echo "Invalid argument: $1"
;;
esac
}
function __hey() {
echo "hey"
}
I would like to prevent that from happening so that the user only sees super_tools
and can provide it further with hey
. Is it possible to do this without unsetting function?
No, there is no concept of private or hidden functions in the shell. In order for something to be runnable, it needs to be visible in the namespace.
There are tools to obfuscate shell scripts, but they basically amount to compiling the code into a native binary which is tedious, but not necessarily hard, to disassemble.