mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-11-19 12:20:52 +01:00
29633: more care with anonymous and other functions
This commit is contained in:
parent
771b059a52
commit
d48faef8cd
4 changed files with 30 additions and 5 deletions
|
|
@ -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>
|
2011-08-03 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 29635: Completion/Base/Widget/_complete_debug: Improve file
|
* 29635: Completion/Base/Widget/_complete_debug: Improve file
|
||||||
|
|
@ -15189,5 +15195,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* 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
|
Arguments to the function may be specified as words following the
|
||||||
closing brace defining the function, hence if there are none no
|
closing brace defining the function, hence if there are none no
|
||||||
arguments (other than tt($0)) are set. Note that this means
|
arguments (other than tt($0)) are set. This is a difference from the
|
||||||
the argument list of any enclosing script or function is hidden.
|
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
|
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
|
to a current-shell structure enclosed in braces. The main use of anonymous
|
||||||
|
|
|
||||||
|
|
@ -1465,7 +1465,10 @@ par_funcdef(void)
|
||||||
ecssub = oecssub;
|
ecssub = oecssub;
|
||||||
YYERRORV(oecused);
|
YYERRORV(oecused);
|
||||||
}
|
}
|
||||||
|
if (num == 0) {
|
||||||
|
/* Anonymous function, possibly with arguments */
|
||||||
incmdpos = 0;
|
incmdpos = 0;
|
||||||
|
}
|
||||||
zshlex();
|
zshlex();
|
||||||
} else if (unset(SHORTLOOPS)) {
|
} else if (unset(SHORTLOOPS)) {
|
||||||
lineno += oldlineno;
|
lineno += oldlineno;
|
||||||
|
|
@ -1721,7 +1724,10 @@ par_simple(int *complex, int nr)
|
||||||
ecssub = oecssub;
|
ecssub = oecssub;
|
||||||
YYERROR(oecused);
|
YYERROR(oecused);
|
||||||
}
|
}
|
||||||
|
if (argc == 0) {
|
||||||
|
/* Anonymous function, possibly with arguments */
|
||||||
incmdpos = 0;
|
incmdpos = 0;
|
||||||
|
}
|
||||||
zshlex();
|
zshlex();
|
||||||
} else {
|
} else {
|
||||||
int ll, sl, c = 0;
|
int ll, sl, c = 0;
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,12 @@
|
||||||
>empty
|
>empty
|
||||||
>here
|
>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
|
%clean
|
||||||
|
|
||||||
rm -f file.in file.out
|
rm -f file.in file.out
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue