function - Bash alias name from a variable -


is there way make bash alias (or function) name coming variable?

for instance, possible along these lines:

create_alias_with_name() {   alias $1="echo custom alias" } 

or along these lines:

create_func_with_name() {   $1() {     "echo inside function variable name"   } } 

in other words, prefer have kind of function "factory" can register functions me. possible or beyond capabilities of bash?

did try it? first example works fine.

you can make second work adding eval:

create_func_with_name() {   eval "$1() {     echo inside function variable name   }" } 

Comments