Skip to content

Instantly share code, notes, and snippets.

@amashigeseiji
Created June 11, 2013 18:30
Show Gist options
  • Save amashigeseiji/5759447 to your computer and use it in GitHub Desktop.
Save amashigeseiji/5759447 to your computer and use it in GitHub Desktop.
function testfunc(){
local num=0
local property pre_func_def pre_count new_func_def
pre_func_def=$(which testfunc)
pre_count=$(echo $pre_func_def|awk 'NR==2 {print $2}')
property=$(echo $pre_func_def|awk 'NR==2 {print $2}'|awk -F'=' '{print $1}')
new_count=${property}'='$(expr $num + 1)
new_func_def=$(echo $pre_func_def|sed -e "s/local $pre_count/local $new_count/")
eval $new_func_def
echo $num
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment