<div dir="ltr"><div>Actually, when I sourced the file with the function and ran the function with a return or exit, it exited the parent shell!<br><br></div>ABSG didn't seem to answer my question, though I mostly read the functions part. <br>
<br>Leam<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 17, 2013 at 12:13 PM, JD <span dir="ltr"><<a href="mailto:jdp@algoloma.com" target="_blank">jdp@algoloma.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Whenever I have a question about Bash, checking the ABSG usually answers it.<br>
<a href="http://www.tldp.org/LDP/abs/html/" target="_blank">http://www.tldp.org/LDP/abs/html/</a><br>
<div><div class="h5"><br>
On 09/17/2013 06:06 PM, leam hall wrote:<br>
> I've looked at a few google searches and am not sure I understand what I'm<br>
> seeing. In bash, I want to have a function do a test, and have a variable in the<br>
> calling program set based on the function's actions. So far it seems as if I<br>
> have to either "echo" the result or have the calling function use $?.<br>
><br>
> Calling script:<br>
><br>
> MY_VAR=`my_function`<br>
><br>
> # This fails:<br>
> my_function() {<br>
> do_something<br>
> return $?<br>
> }<br>
><br>
> # This works:<br>
> my_function() {<br>
> do_something<br>
> if [ $? -eq 0 ]<br>
> echo 0<br>
> else<br>
> echo 1<br>
> fi<br>
> }<br>
><br>
> The first function works if the parent's calls:<br>
><br>
> MY_VAR=`my_function; echo $?`<br>
><br>
> Am I looking for something that's just not in bash?<br>
><br>
> Leam<br>
<br>
</div></div>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div><a href="http://leamhall.blogspot.com/" target="_blank">Mind on a Mission</a></div>
</div>