mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
30718: emulate command evaluations should apply sticky emulation
to autoloads, too
This commit is contained in:
parent
fff9a871e4
commit
321471891e
5 changed files with 75 additions and 10 deletions
|
@ -1,3 +1,9 @@
|
|||
2012-10-07 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 30718: README, Doc/Zsh/builtins.yo, Src/builtin.c,
|
||||
Test/C04funcdef.ztst: emulate command evaluations should apply
|
||||
sticky emulation to autoloads, too.
|
||||
|
||||
2012-10-07 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* unposted: Completion/Unix/Command/_webbrowser,
|
||||
|
@ -233,5 +239,5 @@
|
|||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.5737 $
|
||||
* $Revision: 1.5738 $
|
||||
*****************************************************
|
||||
|
|
|
@ -137,10 +137,19 @@ With the tt(-w) flag, the var(name)s are taken as names of files compiled
|
|||
with the tt(zcompile) builtin, and all functions defined in them are
|
||||
marked for autoloading.
|
||||
|
||||
The flags tt(-z) and tt(-k) mark the function to be autoloaded in
|
||||
native or ksh emulation, as if the option tt(KSH_AUTOLOAD) were
|
||||
unset or were set, respectively. The flags override the setting of
|
||||
the option at the time the function is loaded.
|
||||
The flags tt(-z) and tt(-k) mark the function to be autoloaded using the
|
||||
zsh or ksh style, as if the option tt(KSH_AUTOLOAD) were unset or were
|
||||
set, respectively. The flags override the setting of the option at the
|
||||
time the function is loaded.
|
||||
|
||||
Note that the tt(autoload) command makes no attempt to ensure the
|
||||
shell options set during the loading or execution of the file have
|
||||
any particular value. For this, the tt(emulate) command can be used:
|
||||
|
||||
example(emulate zsh -c 'autoload -Uz var(func)')
|
||||
|
||||
arranges that when var(func) is loaded the shell is in native tt(zsh)
|
||||
emulation, and this emulation is also applied when var(func) is run.
|
||||
)
|
||||
findex(bg)
|
||||
cindex(jobs, backgrounding)
|
||||
|
@ -393,6 +402,7 @@ ifnzman(noderef(Invocation))\
|
|||
ifzman(the section INVOCATION in zmanref(zsh)),
|
||||
except that `tt(-o EMACS)' and `tt(-o VI)' may not be used. Flags such
|
||||
as `tt(+r)'/`tt(+o RESTRICTED)' may be prohibited in some circumstances.
|
||||
|
||||
If tt(-c) var(arg) appears in var(flags), var(arg) is evaluated while the
|
||||
requested emulation is temporarily in effect. In this case the emulation
|
||||
mode and all options are restored to their previous values before
|
||||
|
@ -409,7 +419,10 @@ If the function is called when the sticky emulation is already in
|
|||
effect, either within an `tt(emulate) var(shell) tt(-c)' expression or
|
||||
within another function with the same sticky emulation, entry and exit
|
||||
from the function do not cause options to be altered (except due to
|
||||
standard processing such as the tt(LOCAL_OPTIONS) option).
|
||||
standard processing such as the tt(LOCAL_OPTIONS) option). This also
|
||||
applies to functions marked for autoload within the sticky emulation;
|
||||
the appropriate set of options will be applied at the point the
|
||||
function is loaded as well as when it is run.
|
||||
|
||||
For example:
|
||||
|
||||
|
|
34
README
34
README
|
@ -30,8 +30,38 @@ Zsh is a shell with lots of features. For a list of some of these, see the
|
|||
file FEATURES, and for the latest changes see NEWS. For more
|
||||
details, see the documentation.
|
||||
|
||||
Possible incompatibilities
|
||||
---------------------------
|
||||
Incompatibilities between 5.0.0 and 5.0.1
|
||||
-----------------------------------------
|
||||
|
||||
In 5.0.0, the new "sticky" emulation feature was applied to functions
|
||||
explicitly declared within an expression following `emulate ... -c', but
|
||||
did not apply to functions marked for autoload in that expression. This
|
||||
was not documented and experience suggests it was inconvenient, so in
|
||||
5.0.1 autoloads also have the sticky property.
|
||||
|
||||
In other words,
|
||||
|
||||
emulate zsh -c 'func() { ... }'
|
||||
|
||||
behaves the same way in 5.0.0 and 5.0.1, with the function func always being
|
||||
run in native zsh emulation regardless of the current option settings.
|
||||
However,
|
||||
|
||||
emulate zsh -c 'autoload -Uz func'
|
||||
|
||||
behaves differently: in 5.0.0, func was loaded with the options in
|
||||
effect at the point where it was first run, and subsequently run with
|
||||
whatever options were in effect at that point; in 5.0.1, func is loaded
|
||||
with native zsh emulation options and run with those same options. This
|
||||
is now the recommended way of ensuring a function is loaded and run with
|
||||
a consistent set of options.
|
||||
|
||||
Note that the `autoload -z' has never affected the options applied when
|
||||
the function is loaded or run, only the effect of the KSH_AUTOLOAD
|
||||
option at the point the function is loaded.
|
||||
|
||||
Possible incompatibilities between 4.2 and 5.0
|
||||
----------------------------------------------
|
||||
|
||||
Here are some incompatibilities in the shell since the 4.2 series of
|
||||
releases. It is hoped most users will not be adversely affected by these.
|
||||
|
|
|
@ -2944,8 +2944,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
|
|||
shf = (Shfunc) zshcalloc(sizeof *shf);
|
||||
shf->node.flags = on;
|
||||
shf->funcdef = mkautofn(shf);
|
||||
/* No sticky emulation for autoloaded functions */
|
||||
shf->emulation = 0;
|
||||
shf->emulation = sticky_emulation;
|
||||
shfunctab->addnode(shfunctab, ztrdup(*argv), shf);
|
||||
|
||||
if (signum != -1) {
|
||||
|
|
|
@ -251,6 +251,23 @@
|
|||
>foo1
|
||||
>bar2
|
||||
|
||||
(
|
||||
setopt ignorebraces
|
||||
fpath=(.)
|
||||
print "{ echo OK }\n[[ -o ignorebraces ]] || print 'ignorebraces is off'" \
|
||||
>emufunctest
|
||||
(autoload -z emufunctest; emufunctest) 2>&1
|
||||
emulate zsh -c 'autoload -Uz emufunctest'
|
||||
emufunctest
|
||||
[[ -o ignorebraces ]] && print 'ignorebraces is still on here'
|
||||
)
|
||||
0:sticky emulation applies to autoloads and autoloaded function execution
|
||||
>emufunctest:3: parse error near `\n'
|
||||
>OK
|
||||
>ignorebraces is off
|
||||
>ignorebraces is still on here
|
||||
|
||||
|
||||
%clean
|
||||
|
||||
rm -f file.in file.out
|
||||
|
|
Loading…
Reference in a new issue