diff options
author | jilles <jilles@FreeBSD.org> | 2010-08-15 21:06:53 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-08-15 21:06:53 +0000 |
commit | 0328c8f214dbaa310380c458939f9e4448034c61 (patch) | |
tree | 620517973602d815bb3ce3bfb1defa5a51ba823e /bin | |
parent | 380ff6898aebf17296366587520525edc0ca6935 (diff) | |
download | FreeBSD-src-0328c8f214dbaa310380c458939f9e4448034c61.zip FreeBSD-src-0328c8f214dbaa310380c458939f9e4448034c61.tar.gz |
sh: Fix break/continue/return sometimes not skipping the rest of dot script.
In our implementation and most others, a break or continue in a dot script
can break or continue a loop outside the dot script. This should cause all
further commands in the dot script to be skipped. However, cmdloop() did not
know about this and continued to parse and execute commands from the dot
script.
As described in the man page, a return in a dot script in a function returns
from the function, not only from the dot script. There was a similar issue
as with break and continue. In various other shells, the return appears to
return from the dot script, but POSIX seems not very clear about this.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/main.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/sh/main.c b/bin/sh/main.c index 15ee9e7..b9e4424 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -232,8 +232,9 @@ cmdloop(int top) } popstackmark(&smark); setstackmark(&smark); - if (evalskip == SKIPFILE) { - evalskip = 0; + if (evalskip != 0) { + if (evalskip == SKIPFILE) + evalskip = 0; break; } } |