
{"id":17177,"date":"2018-09-17T19:45:38","date_gmt":"2018-09-17T19:45:38","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=17177"},"modified":"2018-09-17T19:45:38","modified_gmt":"2018-09-17T19:45:38","slug":"caller-returns-the-context-of-any-active-subroutine-call","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2018\/09\/17\/caller-returns-the-context-of-any-active-subroutine-call\/","title":{"rendered":"caller &#8212; returns the context of any active subroutine call"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">$cat test.bash<br \/>!\/bin\/bash<br \/>\ndie() {\n  local frame=0\n  while caller $frame; do\n    ((frame++));\n  done\n  echo \"$*\"\n  exit 1\n}<br \/>\nf1() { die \"*** an error occured ***\"; }\nf2() { f1; }\nf3() { f2; }\n<br \/>f3\n$<div><br \/><\/div><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$bash test.bash \n12 f1 test.bash\n13 f2 test.bash\n14 f3 test.bash\n16 main test.bash\n*** an error occured ***\n$chmod +x test.bash\n$.\/test.bash \n12 f1 .\/test.bash\n13 f2 .\/test.bash\n14 f3 .\/test.bash\n16 main .\/test.bash\n*** an error occured ***\n$<br \/><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$cat test.bash!\/bin\/bash die() { local frame=0 while caller $frame; do ((frame++)); done echo &#8220;$*&#8221; exit 1 } f1() { die &#8220;*** an error occured ***&#8221;; } f2() { f1; } f3() { f2; } f3 $ $bash test.bash 12 f1 test.bash 13 f2 test.bash 14 f3 test.bash 16 main test.bash *** an error occured *** &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2018\/09\/17\/caller-returns-the-context-of-any-active-subroutine-call\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;caller &#8212; returns the context of any active subroutine call&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,112],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/17177"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=17177"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/17177\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=17177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=17177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=17177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}