mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-26 22:10:45 +02:00
29633: more care with anonymous and other functions
This commit is contained in:
parent
771b059a52
commit
d48faef8cd
@ -1,3 +1,9 @@
|
||||
2011-08-03 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 29633: Doc/Zsh/func.yo, Src/parse.c, Test/C04funcdef.ztst: be
|
||||
more careful that anonymous function syntax doesn't mess up
|
||||
working syntax with other functions.
|
||||
|
||||
2011-08-03 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 29635: Completion/Base/Widget/_complete_debug: Improve file
|
||||
@ -15189,5 +15195,5 @@
|
||||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.5413 $
|
||||
* $Revision: 1.5414 $
|
||||
*****************************************************
|
||||
|
@ -162,8 +162,15 @@ is not stored for future use. The function name is set to `tt((anon))'.
|
||||
|
||||
Arguments to the function may be specified as words following the
|
||||
closing brace defining the function, hence if there are none no
|
||||
arguments (other than tt($0)) are set. Note that this means
|
||||
the argument list of any enclosing script or function is hidden.
|
||||
arguments (other than tt($0)) are set. This is a difference from the
|
||||
way other functions are parsed: normal function definitions may be
|
||||
followed by certain keywords such as `tt(else)' or `tt(fi)', which will
|
||||
be treated as arguments to anonymous functions, so that a newline or
|
||||
semicolon is needed to force keyword interpretation.
|
||||
|
||||
Note also that the argument list of any enclosing script or function is
|
||||
hidden (as would be the case for any other function called at this
|
||||
point).
|
||||
|
||||
Redirections may be applied to the anonymous function in the same manner as
|
||||
to a current-shell structure enclosed in braces. The main use of anonymous
|
||||
|
10
Src/parse.c
10
Src/parse.c
@ -1465,7 +1465,10 @@ par_funcdef(void)
|
||||
ecssub = oecssub;
|
||||
YYERRORV(oecused);
|
||||
}
|
||||
incmdpos = 0;
|
||||
if (num == 0) {
|
||||
/* Anonymous function, possibly with arguments */
|
||||
incmdpos = 0;
|
||||
}
|
||||
zshlex();
|
||||
} else if (unset(SHORTLOOPS)) {
|
||||
lineno += oldlineno;
|
||||
@ -1721,7 +1724,10 @@ par_simple(int *complex, int nr)
|
||||
ecssub = oecssub;
|
||||
YYERROR(oecused);
|
||||
}
|
||||
incmdpos = 0;
|
||||
if (argc == 0) {
|
||||
/* Anonymous function, possibly with arguments */
|
||||
incmdpos = 0;
|
||||
}
|
||||
zshlex();
|
||||
} else {
|
||||
int ll, sl, c = 0;
|
||||
|
@ -245,6 +245,12 @@
|
||||
>empty
|
||||
>here
|
||||
|
||||
if true; then f() { echo foo1; } else f() { echo bar1; } fi; f
|
||||
if false; then f() { echo foo2; } else f() { echo bar2; } fi; f
|
||||
0:Compatibility with other shells when not anonymous functions
|
||||
>foo1
|
||||
>bar2
|
||||
|
||||
%clean
|
||||
|
||||
rm -f file.in file.out
|
||||
|
Loading…
Reference in New Issue
Block a user