From: Uwe Kleine-König Date: Tue, 24 Mar 2009 20:46:23 +0000 (+0100) Subject: don't use return when being sourced X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=commitdiff_plain;h=47a84875b594522b6a6441cc1837f98b92742305 don't use return when being sourced Fabien Thomas reports that a Bourne (not Again) sh on FreeBSD just ignores the return and continues executing with the rest of the script. So just wrap everything that was skipped by the return using other shells in a big if instead. Signed-off-by: Uwe Kleine-König Closes: http://bugs.debian.org/516188 --- diff --git a/tg.sh b/tg.sh index 43d1c9f..0804f73 100644 --- a/tg.sh +++ b/tg.sh @@ -340,8 +340,9 @@ setup_hook "pre-commit" ## Dispatch # We were sourced from another script for our utility functions; -# this is set by hooks. -[ -z "$tg__include" ] || return 0 +# this is set by hooks. Skip the rest of the file. A simple return doesn't +# work as expected in every shell. See http://bugs.debian.org/516188 +if [ -z "$tg__include" ]; then if [ "$1" = "-r" ]; then shift @@ -374,4 +375,6 @@ help|--help|-h) . "@cmddir@"/tg-$cmd;; esac +fi + # vim:noet