Skip to content

Instantly share code, notes, and snippets.

@ormaaj ormaaj/funcname.ksh
Last active Jul 2, 2019

Embed
What would you like to do?
#!/usr/bin/env ksh
typeset -a FUNCNAME
function FUNCNAME.get {
nameref self=${.sh.name}
if (( .sh.subscript < .sh.level )); then
trap "(( .sh.level -= .sh.subscript + 1 )); eval '(( .sh.level = ${.sh.level} ))' \; _=\${.sh.fun}" DEBUG
trap - DEBUG;
fi
(( .sh.subscript < .sh.level - 2 )) && self[.sh.subscript + 1]=
}
function f {
if (($1 < 10)); then
print -r -- "${FUNCNAME[@]}"
g $(($1 + 1))
fi
print -r -- "${FUNCNAME[@]}"
}
function g {
if (($1 < 10)); then
print -r -- "${FUNCNAME[@]}"
f $(($1 + 1))
fi
print -r -- "${FUNCNAME[@]}"
}
#typeset -ft FUNCNAME.get f g
f 0
f
g f
f g f
g f g f
f g f g f
g f g f g f
f g f g f g f
g f g f g f g f
f g f g f g f g f
g f g f g f g f g f
f g f g f g f g f g f
g f g f g f g f g f
f g f g f g f g f
g f g f g f g f
f g f g f g f
g f g f g f
f g f g f
g f g f
f g f
g f
f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.