From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: minor module tweak
Date: Fri, 23 Mar 2007 14:18:44 +0000 [thread overview]
Message-ID: <200703231418.l2NEIjGi001132@news01.csr.com> (raw)
While playing about with zmodload I noted that a failed zmodload
doesn't flag an error, so you can use it as a test for module
availability. I've interpreted this as a feature and documented it.
I've changed some zerr()'s that were saving errflag to zwarn()'s that
don't need to. I think this is just because we didn't always have the
complete set of interfaces.
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.90
diff -u -r1.90 builtins.yo
--- Doc/Zsh/builtins.yo 19 Dec 2006 10:35:55 -0000 1.90
+++ Doc/Zsh/builtins.yo 23 Mar 2007 14:18:00 -0000
@@ -1864,7 +1864,13 @@
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
Index: Src/module.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/module.c,v
retrieving revision 1.24
diff -u -r1.24 module.c
--- Src/module.c 6 Feb 2007 21:47:54 -0000 1.24
+++ Src/module.c 23 Mar 2007 14:18:00 -0000
@@ -439,11 +439,8 @@
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 @@
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;
}
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview
next reply other threads:[~2007-03-23 14:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-23 14:18 Peter Stephenson [this message]
2007-03-23 15:39 ` Bart Schaefer
2007-03-23 15:48 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200703231418.l2NEIjGi001132@news01.csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).