Is it possible to define a function but use a variable to compose its name?
_internal_add_deployment_aliases(){
environment=$1
instanceNumber=$2
shortName=$3
instance="${environment}${instanceNumber}"
ipVar="_ip_$instance"
ip=${!ipVar}
# lots of useful aliases
_full_build_${instance}(){ # how do i dynamically define a function using a variable in its name
#something useful
}
}
Context: I'd like to add bunch of aliases and convenience functions to work with my cloud instances, defining aliases is not a problem, I can easily do
alias _ssh_into_${instance}="ssh -i \"${KEY}\" root@$ip"
and I want to have specific aliases defined when I source from this...
Now when i want to do the same for functions i have a problem, is it possible to do this?
Any help is very very much appreciated :)