about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-03-23 14:24:33 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-03-23 14:24:33 +0000
commit11bbce3a66aeb8c2b8832a8ee1657e3fa2e8dc4b (patch)
treeabcb6f075da7a3cf3b49adebf1b5508357d3eaef
parent949152124b559855a58e02c462f13cbc662f64c9 (diff)
downloadzsh-11bbce3a66aeb8c2b8832a8ee1657e3fa2e8dc4b.tar.gz
zsh-11bbce3a66aeb8c2b8832a8ee1657e3fa2e8dc4b.tar.xz
zsh-11bbce3a66aeb8c2b8832a8ee1657e3fa2e8dc4b.zip
23232: minor tweaks to zmodload
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/builtins.yo8
-rw-r--r--Src/module.c12
3 files changed, 16 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index dc91eb85a..ff17bc897 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-23  Peter Stephenson  <pws@csr.com>
+
+	* 23232: Src/module.c, Doc/Zsh/builtins.yo: improve
+	warning interface; record that zmodload doesn't flag an error
+	on failed loading.
+
 2007-03-22  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 23228: Functions/Calendar/calendar_{scan,show}date: fix
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index e84084cd4..aca1cceca 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1864,7 +1864,13 @@ be in a file with a name consisting of the specified var(name) followed by
 a standard suffix, usually `tt(.so)' (`tt(.sl)' on HPUX).
 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.
+ignored.  Otherwise tt(zmodload) prints an error message and returns
+a non-zero status.  The current code block is not aborted unless
+tt(zmodload) detects an inconsistency, such as an invalid module name
+or circular dependency list.  Hence `tt(zmodload -i) 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
+is not available, non-zero status is silently returned.
 
 The var(name)d module is searched for in the same way a command is, using
 tt($module_path) instead of tt($path).  However, the path search is
diff --git a/Src/module.c b/Src/module.c
index fa6d50c6e..ffa659efc 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -439,11 +439,8 @@ do_load_module(char const *name, int silent)
     void *ret;
 
     ret = try_load_module(name);
-    if (!ret && !silent) {
-	int waserr = errflag;
-	zerr("failed to load module: %s", name);
-	errflag = waserr;
-    }
+    if (!ret && !silent)
+	zwarn("failed to load module: %s", name);
     return ret;
 }
 
@@ -454,11 +451,8 @@ do_load_module(char const *name, int silent)
 static void *
 do_load_module(char const *name, int silent)
 {
-    int waserr = errflag;
-
     if (!silent)
-	zerr("failed to load module: %s", name);
-    errflag = waserr;
+	zwarn("failed to load module: %s", name);
 
     return NULL;
 }