Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Crash with =~ in script, but not interactively
- X-seq: zsh-workers 24357
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: zsh-workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: Crash with =~ in script, but not interactively
- Date: Fri, 4 Jan 2008 16:38:35 +0100
- 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=
- In-reply-to: <20080104144237.0eac6c2b@news01>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <237967ef0801040127k49e92485rf09ce72c47d076c5@xxxxxxxxxxxxxx> <20080104144237.0eac6c2b@news01>
On 04/01/2008, Peter Stephenson <pws@xxxxxxx> wrote:
> On Fri, 4 Jan 2008 10:27:40 +0100
> "Mikael Magnusson" <mikachu@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author