関数はサブシェルじゃないよ

http://thagita.blogspot.com/2008/02/bash.html

exit
を使うとスクリプト自体が終了・・・
サブシェルだけ終了すると思っていたのに〜.

関数は通常は同じシェル内で実行されるので、exitしたら終わっちゃうよ。
サブシェルってのはこれですよ。

#!/bin/sh

afunction() {
    echo func
    exit
}

echo first

( echo other_shell; exit; )

echo end_other_shell

afunction

echo end

結果

first
other_shell
end_other_shell
func