I'm looking for something similar to Bash's built-in command
that will only run something if it is a function. So currently I have an insecure way of doing:
# Go through arguments in order
for i in $*; do
if [ -z `which $i` ]; then
# Run function
$i && echo -n ' '
fi
done
This if statement doesn't work properly. Anyway, even if I could check if it's a command and not a function, I can't run explicitly run a function, which is bad because if anyone has any programs in $PATH that are the same name as my function, they will be run. If I nullify PATH or set it to anything else, anyone could still use $i to run a program explicit, so that's also not a solution.
Any way I can "secure" my shell script?
xargs
to run certain bash functions? I dunno, I feel pretty limited with bash compared to something like Python, Perl or even C where I know if I run the name of a function from an argument, it's not going to run anything else.