Subject: return vs. exit
To: None <netbsd-help@netbsd.org>
From: Lubos Vrbka <shnek@chemi.muni.cz>
List: netbsd-help
Date: 03/27/2003 13:14:58
hi guys,

i've following question - what's the general difference between
exit [value]
and
return [value]

in shell script (/bin/sh). i'm not sure. is it:
exit - abort processing of the whole script
return - abort processing of the innermost cycle/operation (i.e. abort 
currently processed while, for, case)

or do they have almost the same effect? i've shellscript that's calling 
other shellscripts and i want to handle errors by myself - but i don't 
know whether i should use exit or return to get back to the script above 
  with the proper error code...

i was trying to look in man, but there's only
exit(3) - c-function; return (tcl-built in); man sh tells me, that 
return terminates the currently executing function - but i don't know 
whether it's the whole shellscript or just a small part; he same applies 
to exit, that terminates the shell process...

thanks for help.

regards,
lubos

-- 
-
#################################################
Lubos Vrbka
National Centre for Biomolecular Research
Masaryk university, Brno, Czech Republic

shnek@chemi.muni.cz
http://www.chemi.muni.cz/~shnek
tel. +420 541 129 508
#################################################