
{"id":17023,"date":"2018-04-07T17:33:50","date_gmt":"2018-04-07T17:33:50","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=17023"},"modified":"2018-04-07T17:33:50","modified_gmt":"2018-04-07T17:33:50","slug":"tinkering-with-trap-and-exit-commands","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2018\/04\/07\/tinkering-with-trap-and-exit-commands\/","title":{"rendered":"Tinkering with trap and exit commands"},"content":{"rendered":"<p><u>TYPICAL COMMANDLINE SESSION<\/u><br \/>\n[bash]<br \/>\n$echo $?<br \/>\n0<br \/>\n$echo $?<br \/>\n0<br \/>\n$exit 10 | tee solve.txt<br \/>\n$cat solve.txt<br \/>\n$rm solve.txt<br \/>\n$exit 10 | echo $?<br \/>\n0<br \/>\n$exit -1 | echo $?<br \/>\n0<br \/>\n$exit -1 | echo $?<br \/>\n0<br \/>\n$false | true<br \/>\n$echo $?<br \/>\n0<br \/>\n$false<br \/>\n$echo $?<br \/>\n1<br \/>\n$true<br \/>\n$echo $?<br \/>\n0<br \/>\n$exit 5 | tee var=$?<br \/>\n$file var\\=0<br \/>\nvar=0: empty<br \/>\n$type var<br \/>\nbash: type: var: not found<br \/>\n$file var\\=0<br \/>\nvar=0: empty<br \/>\n$<br \/>\n[\/bash]<\/p>\n<p>[bash]<br \/>\n$trap $? &gt; solve.txt exit 10<br \/>\n$cat solve.txt<br \/>\nDisplay all 296 possibilities? (y or n)<br \/>\n$cat solve.txt<br \/>\n$trap echo $? &gt; solve.txt exit 10<br \/>\n$cat solve.txt<br \/>\n$trap `echo $? &gt; solve.txt` exit 10<br \/>\n$cat solve.txt<br \/>\n0<br \/>\n$<br \/>\n[\/bash]<\/p>\n<p>[bash]<br \/>\n$bash -c &#8216;exit 7&#8217;; echo $?<br \/>\n7<br \/>\n$bash -c `exit 7`; echo $?<br \/>\nbash: -c: option requires an argument<br \/>\n2<br \/>\n$bash -c &#8216;exit 7&#8217;; echo $?<br \/>\n7<br \/>\n$trap &#8216;echo $? &gt; solve.txt&#8217; exit 10<br \/>\n$cat solve.txt<br \/>\n0<br \/>\n$cat solve.txt<br \/>\n0<br \/>\n$bash -c &#8216;exit 11&#8217;; echo $?<br \/>\n11<br \/>\n$<br \/>\n[\/bash]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TYPICAL COMMANDLINE SESSION [bash] $echo $? 0 $echo $? 0 $exit 10 | tee solve.txt $cat solve.txt $rm solve.txt $exit 10 | echo $? 0 $exit -1 | echo $? 0 $exit -1 | echo $? 0 $false | true $echo $? 0 $false $echo $? 1 $true $echo $? 0 $exit 5 | tee &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2018\/04\/07\/tinkering-with-trap-and-exit-commands\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Tinkering with trap and exit commands&#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":[83],"tags":[556,730,740,742],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/17023"}],"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=17023"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/17023\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=17023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=17023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=17023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}