From: "Mikael Magnusson" <mikachu@gmail.com>
To: zsh-workers <zsh-workers@sunsite.dk>
Subject: Re: Crash with =~ in script, but not interactively
Date: Fri, 4 Jan 2008 16:38:35 +0100 [thread overview]
Message-ID: <237967ef0801040738q3a3287ffy1994fe4b0d6155e4@mail.gmail.com> (raw)
In-Reply-To: <20080104144237.0eac6c2b@news01>
On 04/01/2008, Peter Stephenson <pws@csr.com> wrote:
> 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).
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
next prev parent reply other threads:[~2008-01-04 15:38 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
2008-01-04 15:38 ` Mikael Magnusson [this message]
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=237967ef0801040738q3a3287ffy1994fe4b0d6155e4@mail.gmail.com \
--to=mikachu@gmail.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).