Comments on: Deeper into Function Complexities with Shell Scripting – Part VII https://www.tecmint.com/deeper-into-function-complexities-with-shell-scripting-part-vii/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Mon, 05 Oct 2015 17:23:21 +0000 hourly 1 By: Anoop C S https://www.tecmint.com/deeper-into-function-complexities-with-shell-scripting-part-vii/comment-page-1/#comment-679582 Mon, 05 Oct 2015 17:23:21 +0000 http://www.tecmint.com/?p=5886#comment-679582 Try to understand the difference based on the output of following shell script:

#!/bin/bash

function return_func () {
echo “I’m returning, but not exiting . . .”
return 1
echo “This will not be displayed :-)”
}

function exit_func () {
echo “I’m exiting . . .”
exit 0
echo “This will not be displayed :-)”
}

echo
echo “Before returning.”
echo
return_func
if [ $? -eq 1 ]; then
echo
echo “Before exiting.”
echo
exit_func
fi
echo
echo “And you will not see this on execution”
exit 2

Check the output status using $? immediately after the execution of the above script. I hope that’s clear.

]]>
By: Aaron Kili K https://www.tecmint.com/deeper-into-function-complexities-with-shell-scripting-part-vii/comment-page-1/#comment-676826 Wed, 30 Sep 2015 14:13:28 +0000 http://www.tecmint.com/?p=5886#comment-676826 what is the difference between a return statement and an exit statement in shell functions.

Could you explain with some brief examples.

]]>