
{"id":18010,"date":"2019-02-25T20:06:09","date_gmt":"2019-02-25T20:06:09","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=18010"},"modified":"2019-02-25T20:06:09","modified_gmt":"2019-02-25T20:06:09","slug":"bash-and-return-command","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2019\/02\/25\/bash-and-return-command\/","title":{"rendered":"Understanding bash fundamentals and also about return command"},"content":{"rendered":"<p><u>ABOUT return<\/u><\/p>\n<pre>\nCauses  a  function to stop executing and return the value specified by n to its caller.  If n is\nomitted, the return status is that of the last command executed in the function body.\n<\/pre>\n<p><u>TYPICAL COMMAND LINE EXPOSURE<\/u><br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\necho &quot;10&quot;<br \/>\n}<\/p>\n<p>e<br \/>\nvalue=e<br \/>\n#echo $value<\/p>\n<p>$bash .\/learn<br \/>\nhello<br \/>\n10<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\necho &quot;10&quot;<br \/>\n}<\/p>\n<p>value=e<br \/>\necho $value<\/p>\n<p>$bash .\/learn<br \/>\ne<br \/>\n$<br \/>\n[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\necho &quot;10&quot;<br \/>\n}<\/p>\n<p>value=$(e)<br \/>\necho $value<\/p>\n<p>$bash .\/learn<br \/>\nhello 10<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\necho &quot;10&quot;<br \/>\n}<\/p>\n<p>value=$(e)<br \/>\n#echo $value<\/p>\n<p>$bash .\/learn<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\necho &quot;10&quot;<br \/>\n}<\/p>\n<p>e<br \/>\nvalue=$(e)<br \/>\n#echo $value<\/p>\n<p>$bash .\/learn<br \/>\nhello<br \/>\n10<br \/>\n$<br \/>\n[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\necho 10<br \/>\n}<\/p>\n<p>e<br \/>\nvalue=$(e)<br \/>\n#echo $value<\/p>\n<p>$bash .\/learn<br \/>\nhello<br \/>\n10<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\nreturn 10<br \/>\n}<\/p>\n<p>e<br \/>\nvalue=$(e)<br \/>\necho $value<\/p>\n<p>$bash .\/learn<br \/>\nhello<br \/>\nhello<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\nreturn 10<br \/>\n}<\/p>\n<p>e<br \/>\nvalue=$(e)<br \/>\necho $value<br \/>\necho $?<\/p>\n<p>$bash .\/learn<br \/>\nhello<br \/>\nhello<br \/>\n0<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\n[bash]<br \/>\n$cat learn<br \/>\nfunction e() {<br \/>\necho hello<br \/>\nreturn 10<br \/>\n}<\/p>\n<p>e<br \/>\necho $?<\/p>\n<p>$bash .\/learn<br \/>\nhello<br \/>\n10<br \/>\n$<\/p>\n<p>[\/bash]<br \/>\nLINKS<br \/>\n<a href=\"https:\/\/ryanstutorials.net\/bash-scripting-tutorial\/bash-functions.php\">https:\/\/ryanstutorials.net\/bash-scripting-tutorial\/bash-functions.php<\/a><br \/>\n<a href=\"https:\/\/stackoverflow.com\/questions\/4419952\/difference-between-return-and-exit-in-bash-functions\">https:\/\/stackoverflow.com\/questions\/4419952\/difference-between-return-and-exit-in-bash-functions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ABOUT return Causes a function to stop executing and return the value specified by n to its caller. If n is omitted, the return status is that of the last command executed in the function body. TYPICAL COMMAND LINE EXPOSURE [bash] $cat learn function e() { echo hello echo &quot;10&quot; } e value=e #echo $value &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2019\/02\/25\/bash-and-return-command\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Understanding bash fundamentals and also about return command&#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,8],"tags":[740,1381,1489],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/18010"}],"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=18010"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/18010\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=18010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=18010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=18010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}