I use zsh (sometimes bash). The thing is that I have multiple shell scripts and I've got no idea how to code a small function for printing function code by it's name (with highlighting; I use pygmentize -g). Here's a small example of what I want to get:
$ getfunc "somefunc"
# from my_little_hacks.sh
somefunc () {
# function code
}
Is it a clean and efficient way to do it in shell or awk without using nl and cat in the best time available for shell interpreter?
It is improbable for a function to have a word function in it's body except for when there are nested ones there. It is also next to impossible that it has a { or } legally unpaired inside the quotes.