From: Peter Stephenson <pws@csr.com>
To: zsh-workers <zsh-workers@sunsite.dk>
Subject: Re: Crash with =~ in script, but not interactively
Date: Fri, 4 Jan 2008 14:42:37 +0000 [thread overview]
Message-ID: <20080104144237.0eac6c2b@news01> (raw)
In-Reply-To: <237967ef0801040127k49e92485rf09ce72c47d076c5@mail.gmail.com>
On Fri, 4 Jan 2008 10:27:40 +0100
"Mikael Magnusson" <mikachu@gmail.com> wrote:
> I was going to make a wrapper script that replaces the :43: in gcc
> warnings with +43 so i can open in vim easierly, but ran into some
> problems.
>
> #!/bin/zsh
> #this makes zsh segfault
> if [[ $#@ = 1 ]]; then
> if [[ $1 =~ /?[^/]+:[0-9]+:$ ]]; then
> echo hello
> fi
> fi
>
> If i save that in a file and run 'zsh file' it crashes, but if i run
> 'source file' in an open shell it works as expected.
Thanks, the problem was fairly obvious (luckily, since debugging the
wordcode is another thing that's a nightmare).
Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.20
diff -u -r1.20 text.c
--- Src/text.c 1 May 2007 22:05:06 -0000 1.20
+++ Src/text.c 4 Jan 2008 14:28:51 -0000
@@ -732,7 +732,8 @@
taddstr(" ");
taddstr(ecgetstr(state, EC_NODUP, NULL));
if (ctype == COND_STREQ ||
- ctype == COND_STRNEQ)
+ ctype == COND_STRNEQ ||
+ ctype == COND_REGEX)
state->pc++;
} else {
/* Unary test: `-f foo' etc. */
Index: Test/C02cond.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C02cond.ztst,v
retrieving revision 1.19
diff -u -r1.19 C02cond.ztst
--- Test/C02cond.ztst 13 Dec 2007 21:21:29 -0000 1.19
+++ Test/C02cond.ztst 4 Jan 2008 14:28:51 -0000
@@ -211,6 +211,18 @@
0:-nt shouldn't abort on non-existent files
>status = 1
+# core dumps on failure
+ if zmodload -i zsh/regex 2>/dev/null; then
+ echo >regex_test.sh 'if [[ $# = 1 ]]; then
+ if [[ $1 =~ /?[^/]+:[0-9]+:$ ]]; then
+ :
+ fi
+ fi
+ exit 0'
+ $ZTST_testdir/../Src/zsh -f ./regex_test.sh
+ fi
+0:regex tests shouldn't crash
+
%clean
# This works around a bug in rm -f in some versions of Cygwin
chmod 644 unmodish
--
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
next prev parent reply other threads:[~2008-01-04 14:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-04 9:27 Mikael Magnusson
2008-01-04 10:35 ` Mikael Magnusson
2008-01-04 14:42 ` Peter Stephenson [this message]
2008-01-04 15:38 ` Mikael Magnusson
2008-01-04 15:47 ` 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=20080104144237.0eac6c2b@news01 \
--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).