about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/builtins.yo13
-rw-r--r--Src/Modules/zftp.c2
-rw-r--r--Src/Zle/zle_thingy.c2
-rw-r--r--Src/builtin.c2
-rw-r--r--Src/module.c12
6 files changed, 23 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 850e87b5c..73fbe1c2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-12  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 41244: Doc/Zsh/builtins.yo, Src/Modules/zftp.c,
+	Src/Zle/zle_thingy.c, Src/builtin.c, Src/module.c: Add zmodload
+	-s (silent) option by exposing low-level argument to builtin.
+
 2017-06-09  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
 	* unposted: Etc/BUGS: Add to Etc/BUGS 41184,41203,41254 about
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 81687c7a7..333db1c2c 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -2554,7 +2554,7 @@ zlecmd(zle)
 findex(zmodload)
 cindex(modules, loading)
 cindex(loading modules)
-xitem(tt(zmodload) [ tt(-dL) ] [ ... ])
+xitem(tt(zmodload) [ tt(-dL) ] [ tt(-s) ] [ ... ])
 xitem(tt(zmodload -F) [ tt(-alLme) tt(-P) var(param) ] var(module) [ [tt(PLUS()-)]var(feature) ... ])
 xitem(tt(zmodload -e) [ tt(-A) ] [ ... ])
 xitem(tt(zmodload) [ tt(-a) [ tt(-bcpf) [ tt(-I) ] ] ] [ tt(-iL) ] ...)
@@ -2573,7 +2573,7 @@ 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) ... )
+xitem(tt(zmodload) [ tt(-is) ] 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
@@ -2581,9 +2581,7 @@ a standard suffix, usually `tt(.so)' (`tt(.sl)' on HPUX).
 If the module to be loaded is already loaded the duplicate module is
 ignored.  If tt(zmodload) detects an inconsistency, such as an
 invalid module name or circular dependency list, the current code block is 
-aborted.   Hence `tt(zmodload) var(module) tt(2>/dev/null)' is sufficient
-to test whether a module is available.
-If it is available, the module is loaded if necessary, while if it
+aborted.  If it is available, the module is loaded if necessary, while if it
 is not available, non-zero status is silently returned.  The option
 tt(-i) is accepted for compatibility but has no effect.
 
@@ -2596,6 +2594,11 @@ If the module supports features (see below), tt(zmodload) tries to
 enable all features when loading a module.  If the module was successfully
 loaded but not all features could be enabled, tt(zmodload) returns status 2.
 
+If the option tt(-s) is given, no error is printed if the module was not
+available (though other errors indicating a problem with the module are
+printed).  The return status indicates if the module was loaded.  This
+is appropriate if the caller considers the module optional.
+
 With tt(-u), tt(zmodload) unloads modules.  The same var(name)
 must be given that was given when the module was loaded, but it is not
 necessary for the module to exist in the file system.
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index deed35e2f..24f4b4200 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -3177,7 +3177,7 @@ static struct features module_features = {
 int
 setup_(UNUSED(Module m))
 {
-    return (require_module("zsh/net/tcp", NULL) == 1);
+    return (require_module("zsh/net/tcp", NULL, 0) == 1);
 }
 
 /**/
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index c003148f8..f7e9829c2 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -602,7 +602,7 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func)
     Thingy t;
     Widget w, cw;
 
-    if (require_module("zsh/complete", NULL) == 1) {
+    if (require_module("zsh/complete", NULL, 0) == 1) {
 	zwarnnam(name, "can't load complete module");
 	return 1;
     }
diff --git a/Src/builtin.c b/Src/builtin.c
index 063644efb..0b3949437 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -131,7 +131,7 @@ static struct builtin builtins[] =
     BUILTIN("whence", 0, bin_whence, 0, -1, 0, "acmpvfsSwx:", NULL),
     BUILTIN("where", 0, bin_whence, 0, -1, 0, "pmsSwx:", "ca"),
     BUILTIN("which", 0, bin_whence, 0, -1, 0, "ampsSwx:", "c"),
-    BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "AFRILP:abcfdilmpue", NULL),
+    BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "AFRILP:abcfdilmpsue", NULL),
     BUILTIN("zcompile", 0, bin_zcompile, 0, -1, 0, "tUMRcmzka", NULL),
 };
 
diff --git a/Src/module.c b/Src/module.c
index 41f142adb..21d68b1ac 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -2326,7 +2326,7 @@ load_module(char const *name, Feature_enables enablesarr, int silent)
 
 /**/
 mod_export int
-require_module(const char *module, Feature_enables features)
+require_module(const char *module, Feature_enables features, int silent)
 {
     Module m = NULL;
     int ret = 0;
@@ -2336,7 +2336,7 @@ require_module(const char *module, Feature_enables features)
     m = find_module(module, FINDMOD_ALIASP, &module);
     if (!m || !m->u.handle ||
 	(m->node.flags & MOD_UNLOAD))
-	ret = load_module(module, features, 0);
+	ret = load_module(module, features, silent);
     else
 	ret = do_module_features(m, features, 0);
     unqueue_signals();
@@ -2972,7 +2972,7 @@ bin_zmodload_load(char *nam, char **args, Options ops)
     } else {
 	/* load modules */
 	for (; *args; args++) {
-	    int tmpret = require_module(*args, NULL);
+	    int tmpret = require_module(*args, NULL, OPT_ISSET(ops,'s'));
 	    if (tmpret && ret != 1)
 		ret = tmpret;
 	}
@@ -3242,7 +3242,7 @@ bin_zmodload_features(const char *nam, char **args, Options ops)
     fep->str = NULL;
     fep->pat = NULL;
 
-    return require_module(modname, features);
+    return require_module(modname, features, OPT_ISSET(ops,'s'));
 }
 
 
@@ -3403,14 +3403,14 @@ ensurefeature(const char *modname, const char *prefix, const char *feature)
     struct feature_enables features[2];
 
     if (!feature)
-	return require_module(modname, NULL);
+	return require_module(modname, NULL, 0);
     f = dyncat(prefix, feature);
 
     features[0].str = f;
     features[0].pat = NULL;
     features[1].str = NULL;
     features[1].pat = NULL;
-    return require_module(modname, features);
+    return require_module(modname, features, 0);
 }
 
 /*