diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2013-09-04 22:10:16 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2013-09-04 22:10:16 +0000 |
commit | 2935c4cc5e7f254d73ee1e3899372d6a1117a221 (patch) | |
tree | 00235be2a41fac24160537f8172d9ce83957898a /tools | |
parent | dbbd7a968b3ace4e451125e41aa9c05bee1d0eca (diff) | |
download | src-2935c4cc5e7f254d73ee1e3899372d6a1117a221.tar.gz src-2935c4cc5e7f254d73ee1e3899372d6a1117a221.zip |
sh: Make return return from the closest function or dot script.
Formerly, return always returned from a function if it was called from a
function, even if there was a closer dot script. This was for compatibility
with the Bourne shell which only allowed returning from functions.
Other modern shells and POSIX return from the function or the dot script,
whichever is closest.
Git 1.8.4's rebase --continue depends on the POSIX behaviour.
Reported by: Christoph Mallon, avg
Notes
Notes:
svn path=/head/; revision=255215
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/builtins/return8.0 | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/return8.0 b/tools/regression/bin/sh/builtins/return8.0 new file mode 100644 index 000000000000..f00e859a74ce --- /dev/null +++ b/tools/regression/bin/sh/builtins/return8.0 @@ -0,0 +1,13 @@ +# $FreeBSD$ + +if [ "$1" = nested ]; then + return 17 +fi + +f() { + set -- nested + . "$0" + return $(($? ^ 1)) +} +f +exit $(($? ^ 16)) |