From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6560 invoked from network); 4 Jan 2008 15:38:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Jan 2008 15:38:49 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 65689 invoked from network); 4 Jan 2008 15:38:44 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Jan 2008 15:38:44 -0000 Received: (qmail 12206 invoked by alias); 4 Jan 2008 15:38:40 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24357 Received: (qmail 12186 invoked from network); 4 Jan 2008 15:38:39 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 4 Jan 2008 15:38:39 -0000 Received: from virusfilter.dotsrc.org (bifrost [127.0.0.1]) by spamfilter.dotsrc.org (Postfix) with ESMTP id 7E8FE8058FF2 for ; Fri, 4 Jan 2008 16:38:37 +0100 (CET) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.182]) by bifrost.dotsrc.org (Postfix) with ESMTP for ; Fri, 4 Jan 2008 16:38:36 +0100 (CET) Received: by py-out-1112.google.com with SMTP id h31so2607753pyc.23 for ; Fri, 04 Jan 2008 07:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=5JKzU7YUpwcHc05eatx/XXZur5XMJKQYUo8JE+Kdwag=; b=t+PIacgQZ9Kn37dTJy75kNZG//YDXoRT5QmFxkkUxYEYTSj44yE/6PmXshduZY3UGH7T8if5YqKyWACikKiWSMJaKDL2E8/DiQj7TJ8/dnpjzK/upfgT43S3vsTjg8yoV9fkG+pKPaFEpqkLeAk60CfboHhZ7lMAsX4UJUHGj8I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=RQ/Hw+D7u/sT/1Vnc996HpBj94l7Hwv5ktWQY0+hJQsKGJ+0tE3pP4FXku+f9W5CXaDkPSRAuCbRwibgoUDseAuhERGeTf+3IozgEI5fk83TlrcisEb5MEDhkiO7xGkEs1wbYJ/ahroIMSW0zkpeXzKzxuXFKBZseLFqwNwwY3A= Received: by 10.140.169.6 with SMTP id r6mr8884995rve.273.1199461115338; Fri, 04 Jan 2008 07:38:35 -0800 (PST) Received: by 10.140.127.7 with HTTP; Fri, 4 Jan 2008 07:38:35 -0800 (PST) Message-ID: <237967ef0801040738q3a3287ffy1994fe4b0d6155e4@mail.gmail.com> Date: Fri, 4 Jan 2008 16:38:35 +0100 From: "Mikael Magnusson" To: zsh-workers Subject: Re: Crash with =~ in script, but not interactively In-Reply-To: <20080104144237.0eac6c2b@news01> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <237967ef0801040127k49e92485rf09ce72c47d076c5@mail.gmail.com> <20080104144237.0eac6c2b@news01> X-Virus-Scanned: ClamAV using ClamSMTP On 04/01/2008, Peter Stephenson wrote: > On Fri, 4 Jan 2008 10:27:40 +0100 > "Mikael Magnusson" 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). Yep that worked. Does the =~ operator support backreferences? I didn't find anything searching through the manual for the word. This is what I ended up with instead which works too: #!/bin/zsh setopt extendedglob if [[ $# = 1 ]]; then if [[ $1 = *[^/]##:(#b)([0-9]##)(#B): ]]; then 2=+${1[$mbegin[1],$mend[1]]} 1=${1[1,$mbegin[1]-2]} fi fi if [[ -z $DISPLAY ]] ; then vim $@; else; gvim $@; fi in case anyone ever wanted something like that. -- Mikael Magnusson