I often generate and register a lot of bash functions that automate many of the task I usually do in my development projects. That generation depends on the meta-data of the project I am working on.
I want to annotate the functions with the info of the project they were generated, this way:
func1() {
# This function was generated for project: PROJECT1
echo "do my automation"
}
Ideally, I would be able to see the comment when I inspect the definition:
$ type func1
func1 is a function
func1 ()
{
# This function was generated for project: PROJECT1
echo "do my automation"
}
But somehow bash seems to ignore the comments at the moment of loading the function, not when executing it. So the comments are lost and I get this result:
func1 is a function
func1 ()
{
echo "do my automation"
}
Is there any way to assign metadata to functions, and check them afterwards? It is possible to retrieve it when inspecting the definition with type?
$1
is-h
, and thenprintf
/echo
a one-line help/usage/whatever.