Subject: Re: exit/return: /bin/sh in netbsd vs. /bin/sh in freebsd
To: Lubos Vrbka <shnek@chemi.muni.cz>
From: David Laight <david@l8s.co.uk>
List: netbsd-help
Date: 04/16/2003 16:22:54
> works under netbsd, fails under freebsd - writes error message about bad
> usage of return and then doesn't return to the calling script, but continues
> with execution... and it of course causes problems...

Ok the standard says:
http://www.opengroup.org/onlinepubs/009604499/utilities/return.html

    The return utility shall cause the shell to stop executing the current
    function or dot script.  If the shell is not currently executing a
    function or dot script, the results are unspecified.

Since these returns are neiher in a shell function, nor in a dot script
both shells obey the standard (even though they behave differently).

In practise you should (as you have found out) not rely on unspecified
behaviour.

You should use 'exit' to terminate a shell.

	David

-- 
David Laight: david@l8s.co.uk