mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-18 21:38:03 +02:00
zsh-workers:6196
This commit is contained in:
parent
05e805b0a8
commit
f5b522981b
4 changed files with 97 additions and 73 deletions
|
@ -1169,30 +1169,26 @@ Equivalent to tt(whence -c).
|
|||
findex(zmodload)
|
||||
cindex(modules, loading)
|
||||
cindex(loading modules)
|
||||
xitem(tt(zmodload) [ tt(-iL) ] [ var(name) ... ])
|
||||
xitem(tt(zmodload) tt(-u) [ tt(-i) ] var(name) ...)
|
||||
xitem(tt(zmodload) tt(-d) [ tt(-L) ] [ var(name) [ var(dep) ... ] ])
|
||||
xitem(tt(zmodload) tt(-du) var(name) [ var(dep) ... ])
|
||||
xitem(tt(zmodload) tt(-a) [ tt(-iL) ] [ var(name) [ var(builtin) ... ] ])
|
||||
xitem(tt(zmodload) tt(-au) [ tt(-i) ] var(builtin) ...)
|
||||
xitem(tt(zmodload) tt(-c) [ tt(-iI) ] var(name) [ var(cond) ... ])
|
||||
xitem(tt(zmodload) tt(-cu) [ tt(-iI) ] var(cond) ...)
|
||||
xitem(tt(zmodload) tt(-c) [ tt(-IL) ])
|
||||
xitem(tt(zmodload) tt(-p) [ tt(-i) ] var(name) [ var(parameter) ... ])
|
||||
xitem(tt(zmodload) tt(-pu) [ tt(-i) ] var(parameter) ... ])
|
||||
item(tt(zmodload) tt(-p) [ tt(-L) ])(
|
||||
xitem(tt(zmodload) [ tt(-dL) ] [ ... ])
|
||||
xitem(tt(zmodload) [ tt(-a) [ tt(-bcp) [ tt(-I) ] ] ] [ tt(-iL) ] ...)
|
||||
item(tt(zmodload) tt(-u) [ tt(-abcdp) [ tt(-I) ] ] [ tt(-iL) ] ...)(
|
||||
tt(zmodload) performs operations relating to zsh's loadable modules.
|
||||
This feature is not available on all operating systems,
|
||||
or on all installations on a particular operating system.
|
||||
|
||||
In the simplest case,
|
||||
tt(zmodload) loads a binary module. The module must be in a file with a
|
||||
name consisting of the specified var(name) followed by a standard suffix,
|
||||
usually `tt(.so)'. If this can't be found, the var(name) is tried without
|
||||
the suffix.
|
||||
If the module to be loaded is already loaded and the tt(-i)
|
||||
option is given, the duplicate module is ignored. Otherwise
|
||||
tt(zmodload) prints an error message.
|
||||
Without arguments all currently loaded binary modules are printed.
|
||||
The tt(-L) option causes this list to be in the form of a series of
|
||||
tt(zmodload) commands. Forms with arguments are:
|
||||
|
||||
startitem()
|
||||
xitem(tt(zmodload) [ tt(-i) ] var(name) ... )
|
||||
item(tt(zmodload) tt(-u) [ tt(-i) ] var(name) ...)(
|
||||
In the simplest case, tt(zmodload) loads a binary module. The module must
|
||||
be in a file with a name consisting of the specified var(name) followed by
|
||||
a standard suffix, usually `tt(.so)'. If this can't be found, the
|
||||
var(name) is tried without the suffix. If the module to be loaded is
|
||||
already loaded and the tt(-i) option is given, the duplicate module is
|
||||
ignored. Otherwise tt(zmodload) prints an error message.
|
||||
|
||||
The var(name)d module is searched for in the same way a command is, using
|
||||
tt($module_path) instead of tt($path). If var(name) contains a `tt(/)',
|
||||
|
@ -1209,55 +1205,66 @@ unloaded (or was never loaded).
|
|||
Each module has a boot and a cleanup function. The module
|
||||
will not be loaded if its boot function fails. Similarly a module
|
||||
can only be unloaded if its cleanup function runs successfully.
|
||||
)
|
||||
xitem(tt(zmodload) tt(-d) [ tt(-L) ] [ var(name) ])
|
||||
xitem(tt(zmodload) tt(-d) var(name) var(dep) ...)
|
||||
item(tt(zmodload) tt(-ud) var(name) [ var(dep) ... ])(
|
||||
The tt(-d) option can be used to specify module dependencies. The modules
|
||||
named in the second and subsequent arguments will be loaded before the
|
||||
module named in the first argument.
|
||||
|
||||
Without arguments all currently loaded binary modules are printed.
|
||||
The tt(-L) option causes this list to be in the form of a series of
|
||||
tt(zmodload) commands.
|
||||
With tt(-d) and one argument, all dependencies for that module are listed.
|
||||
With tt(-d) and no arguments, all module dependencies are listed. This
|
||||
listing is by default in a Makefile-like format. The tt(-L) option
|
||||
changes this format to a list of tt(zmodload -d) commands.
|
||||
|
||||
The tt(-d) option can be used to specify module dependencies.
|
||||
This operation is idempotent regardless of the tt(-i) option.
|
||||
The modules named in the second and subsequent arguments will be
|
||||
loaded before the module named in the first argument.
|
||||
If tt(-d) and tt(-u) are both used, dependencies are removed. If only one
|
||||
argument is given, all dependencies for that module are removed.
|
||||
)
|
||||
xitem(tt(zmodload) tt(-ab) [ tt(-L) ])
|
||||
xitem(tt(zmodload) tt(-ab) [ tt(-i) ] var(name) [ var(builtin) ... ])
|
||||
item(tt(zmodload) tt(-ub) [ tt(-i) ] var(builtin) ...)(
|
||||
The tt(-ab) option defines autoloaded builtins. It defines the specified
|
||||
var(builtin)s. When any of those builtins is called, the module specified
|
||||
in the first argument is loaded. If only the var(name) is given, one
|
||||
builtin is defined, with the same name as the module. tt(-i) suppresses
|
||||
the error if the builtin is already defined or autoloaded, regardless of
|
||||
which module it came from.
|
||||
|
||||
With tt(-d) and one
|
||||
argument, all dependencies for that module are listed. With tt(-d) and no
|
||||
arguments, all module dependencies are listed.
|
||||
This listing is by default in a Makefile-like format.
|
||||
The tt(-L) option changes this format to a list of
|
||||
tt(zmodload -d) commands.
|
||||
With tt(-ab) and no arguments, all autoloaded builtins are listed, with the
|
||||
module name (if different) shown in parentheses after the builtin name.
|
||||
The tt(-L) option changes this format to a list of tt(zmodload -a)
|
||||
commands.
|
||||
|
||||
If tt(-d) and tt(-u) are both used, dependencies are removed.
|
||||
This operation is idempotent regardless of the tt(-i) option.
|
||||
If only one argument is given, all dependencies for that module are removed.
|
||||
|
||||
The tt(-a) option defines autoloaded builtins. It defines the
|
||||
specified var(builtin)s. When any of those builtins is called, the module
|
||||
specified in the first argument is loaded. If only one argument is given,
|
||||
one builtin is defined, with the same name as the module.
|
||||
tt(-i) suppresses the error if the builtin is already defined or
|
||||
autoloaded, regardless of which module it came from.
|
||||
|
||||
With tt(-a) and no arguments, all
|
||||
autoloaded builtins are listed, with the module name (if different)
|
||||
shown in parentheses after the builtin name. The tt(-L) option changes
|
||||
this format to a list of tt(zmodload -a) commands.
|
||||
|
||||
If tt(-a) is used
|
||||
together with the tt(-u) option it removes builtins defined with
|
||||
tt(zmodload -a). This is only possible if the builtin is not yet
|
||||
loaded. tt(-i) suppresses the error if the builtin is already
|
||||
If tt(-b) is used together with the tt(-u) option, it removes builtins
|
||||
previously defined with tt(-ab). This is only possible if the builtin is
|
||||
not yet loaded. tt(-i) suppresses the error if the builtin is already
|
||||
removed (or never existed).
|
||||
|
||||
The tt(-c) option is used to define autoloaded condition codes. The
|
||||
)
|
||||
xitem(tt(zmodload) tt(-ac) [ tt(-IL) ])
|
||||
xitem(tt(zmodload) tt(-ac) [ tt(-iI) ] var(name) [ var(cond) ... ])
|
||||
item(tt(zmodload) tt(-uc) [ tt(-iI) ] var(cond) ...)(
|
||||
The tt(-ac) option is used to define autoloaded condition codes. The
|
||||
var(cond) strings give the names of the conditions defined by the
|
||||
module. The optional tt(-I) option is used to define infix condition
|
||||
names. Without this option prefix condition names are defined.
|
||||
|
||||
Together with the tt(-u) option definitions for autoloaded conditions
|
||||
are removed. If given no condition names all defined names are listed
|
||||
(as a series of tt(zmodload) commands if the tt(-L) option is given).
|
||||
If given no condition names, all defined names are listed (as a series of
|
||||
tt(zmodload) commands if the tt(-L) option is given).
|
||||
|
||||
The tt(-p) option is like the tt(-c) option, but makes tt(zmodload)
|
||||
work on autoloaded parameters instead of condition codes.
|
||||
The tt(-uc) option removes definitions for autoloaded conditions.
|
||||
)
|
||||
xitem(tt(zmodload) tt(-ap) [ tt(-L) ])
|
||||
xitem(tt(zmodload) tt(-ap) [ tt(-i) ] var(name) [ var(parameter) ... ])
|
||||
item(tt(zmodload) tt(-up) [ tt(-i) ] var(parameter) ...)(
|
||||
The tt(-p) option is like the tt(-b) and tt(-c) options, but makes
|
||||
tt(zmodload) work on autoloaded parameters instead.
|
||||
)
|
||||
xitem(tt(zmodload) tt(-a) [ tt(-L) ])
|
||||
xitem(tt(zmodload) tt(-a) [ tt(-i) ] var(name) [ var(builtin) ... ])
|
||||
item(tt(zmodload) tt(-ua) [ tt(-i) ] var(builtin) ...)(
|
||||
Equivalent to tt(-ab) and tt(-ub).
|
||||
)
|
||||
enditem()
|
||||
)
|
||||
enditem()
|
||||
|
|
|
@ -120,7 +120,7 @@ static struct builtin builtins[] =
|
|||
BUILTIN("which", 0, bin_whence, 0, -1, 0, "ampsw", "c"),
|
||||
|
||||
#ifdef DYNAMIC
|
||||
BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "LaudicIp", NULL),
|
||||
BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ILabcdipu", NULL),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1793,7 +1793,9 @@ bin_typeset(char *name, char **argv, char *ops, int func)
|
|||
continue;
|
||||
}
|
||||
if (!typeset_single(name, asg->name,
|
||||
(Param)gethashnode2(paramtab, asg->name),
|
||||
(Param) (paramtab == realparamtab ?
|
||||
gethashnode2(paramtab, asg->name) :
|
||||
paramtab->getnode(paramtab, asg->name)),
|
||||
func, on, off, roff, asg->value, NULL))
|
||||
returnval = 1;
|
||||
}
|
||||
|
@ -1974,7 +1976,9 @@ bin_unset(char *name, char **argv, char *ops, int func)
|
|||
}
|
||||
*ss = 0;
|
||||
}
|
||||
pm = (Param) gethashnode2(paramtab, s);
|
||||
pm = (Param) (paramtab == realparamtab ?
|
||||
gethashnode2(paramtab, s) :
|
||||
paramtab->getnode(paramtab, s));
|
||||
if (!pm)
|
||||
returnval = 1;
|
||||
else if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
|
||||
|
|
27
Src/module.c
27
Src/module.c
|
@ -664,7 +664,7 @@ autoloadscan(HashNode hn, int printflags)
|
|||
if(bn->flags & BINF_ADDED)
|
||||
return;
|
||||
if(printflags & PRINT_LIST) {
|
||||
fputs("zmodload -a ", stdout);
|
||||
fputs("zmodload -ab ", stdout);
|
||||
if(bn->optstr[0] == '-')
|
||||
fputs("-- ", stdout);
|
||||
quotedzputs(bn->optstr, stdout);
|
||||
|
@ -687,7 +687,12 @@ autoloadscan(HashNode hn, int printflags)
|
|||
int
|
||||
bin_zmodload(char *nam, char **args, char *ops, int func)
|
||||
{
|
||||
if(ops['d'] && ops['a']) {
|
||||
if ((ops['b'] || ops['c'] || ops['p']) && !(ops['a'] || ops['u'])) {
|
||||
zwarnnam(nam, "-b, -c, and -p must be combined with -a or -u",
|
||||
NULL, 0);
|
||||
return 1;
|
||||
}
|
||||
if (ops['d'] && ops['a']) {
|
||||
zwarnnam(nam, "-d cannot be combined with -a", NULL, 0);
|
||||
return 1;
|
||||
}
|
||||
|
@ -695,16 +700,20 @@ bin_zmodload(char *nam, char **args, char *ops, int func)
|
|||
zwarnnam(nam, "what do you want to unload?", NULL, 0);
|
||||
return 1;
|
||||
}
|
||||
if(ops['d'])
|
||||
if (ops['d'])
|
||||
return bin_zmodload_dep(nam, args, ops);
|
||||
else if(ops['a'])
|
||||
else if ((ops['a'] || ops['b']) && !(ops['c'] || ops['p']))
|
||||
return bin_zmodload_auto(nam, args, ops);
|
||||
else if (ops['c'] || ops['C'])
|
||||
else if (ops['c'] && !(ops['b'] || ops['p']))
|
||||
return bin_zmodload_cond(nam, args, ops);
|
||||
else if (ops['p'])
|
||||
else if (ops['p'] && !(ops['b'] || ops['c']))
|
||||
return bin_zmodload_param(nam, args, ops);
|
||||
else
|
||||
else if (!(ops['a'] || ops['b'] || ops['c'] || ops['p']))
|
||||
return bin_zmodload_load(nam, args, ops);
|
||||
else
|
||||
zwarnnam(nam, "use only one of -b, -c, or -p", NULL, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**/
|
||||
|
@ -865,7 +874,7 @@ bin_zmodload_cond(char *nam, char **args, char *ops)
|
|||
for (p = condtab; p; p = p->next) {
|
||||
if (p->module) {
|
||||
if (ops['L']) {
|
||||
fputs("zmodload -c", stdout);
|
||||
fputs("zmodload -ac", stdout);
|
||||
if (p->flags & CONDF_INFIX)
|
||||
putchar('I');
|
||||
printf(" %s %s\n", p->module, p->name);
|
||||
|
@ -908,7 +917,7 @@ printautoparams(HashNode hn, int lon)
|
|||
|
||||
if (pm->flags & PM_AUTOLOAD) {
|
||||
if (lon)
|
||||
printf("zmodload -p %s %s\n", pm->u.str, pm->nam);
|
||||
printf("zmodload -ap %s %s\n", pm->u.str, pm->nam);
|
||||
else
|
||||
printf("%s (%s)\n", pm->nam, pm->u.str);
|
||||
}
|
||||
|
|
|
@ -302,7 +302,11 @@ then
|
|||
echo
|
||||
zmodload -d -L
|
||||
echo
|
||||
zmodload -a -L
|
||||
zmodload -ab -L
|
||||
echo
|
||||
zmodload -ac -L
|
||||
echo
|
||||
zmodload -ap -L
|
||||
echo
|
||||
zmodload -L
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue