summaryrefslogtreecommitdiffstats
path: root/bin/sh/sh.1
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-09-04 22:10:16 +0000
committerjilles <jilles@FreeBSD.org>2013-09-04 22:10:16 +0000
commitad7328341af15585f1dee4fbb63f288d2b2917e2 (patch)
tree00235be2a41fac24160537f8172d9ce83957898a /bin/sh/sh.1
parent206a10e8a633f64ba34396341d375e620bba21d2 (diff)
downloadFreeBSD-src-ad7328341af15585f1dee4fbb63f288d2b2917e2.zip
FreeBSD-src-ad7328341af15585f1dee4fbb63f288d2b2917e2.tar.gz
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
Diffstat (limited to 'bin/sh/sh.1')
-rw-r--r--bin/sh/sh.16
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 174788d..ea1d899 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -1145,8 +1145,10 @@ command is
.Pp
.D1 Ic return Op Ar exitstatus
.Pp
-It terminates the current executional scope, returning from the previous
-nested function, sourced script, or shell instance, in that order.
+It terminates the current executional scope, returning from the closest
+nested function or sourced script;
+if no function or sourced script is being executed,
+it exits the shell instance.
The
.Ic return
command is implemented as a special built-in command.
OpenPOWER on IntegriCloud