From 6a0710e954d913e1096893bf3d037667420db3be Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 30 Sep 2016 14:18:34 +0200 Subject: ash: [BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving dotcmd Upstream commit: Date: Sat, 9 Jul 2011 22:05:22 +0800 [BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving dotcmd Currently upon leaving a dotcmd the evalskip state is reset so if a continue/break statement is used within a dot script it would have no effect outside of the dot script. This is inconsistent with other shells. This patch is based on one by Jilles Tjoelker and only clears SKIPFUNC when leaving a dot script. As a result continue/break will remain in effect. It also merges SKIPFUNC/SKIPFILE as they have no practical difference. Signed-off-by: Herbert Xu Signed-off-by: Denys Vlasenko --- shell/ash.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index a1b211ae0..9fd1b55e2 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -8348,7 +8348,6 @@ defun(char *name, union node *func) #define SKIPBREAK (1 << 0) #define SKIPCONT (1 << 1) #define SKIPFUNC (1 << 2) -#define SKIPFILE (1 << 3) #define SKIPEVAL (1 << 4) static smallint evalskip; /* set to SKIPxxx if we are skipping commands */ static int skipcount; /* number of levels to skip */ @@ -9148,7 +9147,7 @@ returncmd(int argc UNUSED_PARAM, char **argv) * If called outside a function, do what ksh does; * skip the rest of the file. */ - evalskip = funcnest ? SKIPFUNC : SKIPFILE; + evalskip = SKIPFUNC; return argv[1] ? number(argv[1]) : exitstatus; } @@ -12330,7 +12329,7 @@ cmdloop(int top) skip = evalskip; if (skip) { - evalskip = 0; + evalskip &= ~SKIPFUNC; return skip & SKIPEVAL; } } -- cgit v1.2.3