From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Using 'command -v' in a shellscript results in a coredump
Date: Thu, 19 Aug 2004 00:11:07 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.61.0408181746400.6030@toltec.zanshin.com> (raw)
In-Reply-To: <2004-08-19T01-13-05@devnull.michael-prokop.at>
On Thu, 19 Aug 2004, Michael Prokop wrote:
> #!/bin/sh
> command -v blub > /dev/null 2>&1
>
> Running it results in 'zsh: segmentation fault (core dumped)'.
The following prevents the core dump without producing any errors from
"make test", but I suspect there's something deeper that should be fixed
instead.
The crash happens whenever 'command -v' or 'command -V' is used with the
POSIXBUILTINS option set.
The problem is that the code in execcmd() near line 1848 assigns 'hn' to
point at the special 'commandbn' struct, but then 1952 is reached and
tries (again) to find the builtin named "command" which fails. Nothing
picks up the error after that and a null 'hn' is eventually dereferenced
by execbuiltin().
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.69
diff -u -r1.69 exec.c
--- Src/exec.c 29 Jul 2004 15:09:51 -0000 1.69
+++ Src/exec.c 19 Aug 2004 07:03:43 -0000
@@ -1949,7 +1949,7 @@
is_shfunc = 1;
break;
}
- if (!(hn = builtintab->getnode(builtintab, cmdarg))) {
+ if (!hn && !(hn = builtintab->getnode(builtintab, cmdarg))) {
if (cflags & BINF_BUILTIN) {
zwarn("no such builtin: %s", cmdarg, 0);
lastval = 1;
next prev parent reply other threads:[~2004-08-19 7:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-18 23:29 Michael Prokop
2004-08-19 7:11 ` Bart Schaefer [this message]
2004-10-07 17:55 ` Michael Prokop
2004-10-08 13:53 ` Clint Adams
2004-10-09 20:50 ` simple question about completion and case William Scott
2004-10-11 22:31 ` Bart Schaefer
2004-10-11 22:29 ` Using 'command -v' in a shellscript results in a coredump Bart Schaefer
2004-10-13 22:09 ` Michael Prokop
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=Pine.LNX.4.61.0408181746400.6030@toltec.zanshin.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@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).