|
From: Luigi S. <gi...@li...> - 2002-11-23 13:11:44
|
On Thu, Nov 21, 2002 at 06:39:59PM +0000, Paul Ardeleanu wrote: > Why are you all so keen in returning a value at the end of main? > > Paul Besides what Ioannis has already said, another good reason to have a program return some value is to ... use the value! :) For instance, I remember that the (now, or soon to be, obsolete) command.com shell allowed to write some script file like the following rv_test.bat ----------- rem use return value of "foo" to choose a label foo if errorlevel 2 goto label2 if errorlevel 1 goto label1 :else echo program "foo" returned 0 (success) goto end :label1 echo program "foo" returned 1 goto end :label2 echo program "foo" returned a value greater or equal to 2 goto end :end -------- I can't test the above right now (running bash :), but it should work -- >> gisan >> Q: Heard about the <ethnic> who couldn't spell? A: He spent the night in a warehouse. |