zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-workers@zsh.org>
Subject: Re: Certain pattern causing shell to crash
Date: Thu, 6 Jan 2011 18:22:01 +0000	[thread overview]
Message-ID: <20110106182201.27da4de9@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20110106160802.GA4655@Xye>

On Thu, 6 Jan 2011 21:38:02 +0530
Raghavendra D Prabhu <raghu.prabhu13@gmail.com> wrote:
> Sourcing following function in a clean shell (zsh -f) followed by
> which or tab completion is causing shell to segfault
> 
> =================
> view () {
>          if [[ -z $1 ]]
>          then
>                  ranger ~/Documents
>          elif [[ $1 =~ ^http:* ]]
>          then
>                  url=${1#*=} 
>                  dest="$HOME/Documents/${1##*/}" 
>                  wget -c --content-disposition -O - -q $url > $dest
>                  detach mupdf -r 143 $dest
>          else
>                  detach mupdf -r 143 "$@"
>          fi
> }
> ======================================

Yes, I can get that.  The following is about the most simple form that
still causes it to happen:

crashme() {
  if [[ $1 =~ ^http:* ]]
  then
    url=${1#*=}
  fi
}
which crashme

It appears that the code that decodes the '=~' expression (it doesn't
happen if I turn that into '=') is causing the state to go awry, so that
the code in the line after the "then" is being read wrongly.  It's got
something to do with the regular expression, too; putting that in
parentheses or otherwise quoting the "^" makes it go away, so it maybe
related to how "^" is handled in this case.  It shouldn't be too hard to
localise; it's a shame that the the wordcode is completely
impenetrable.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


  reply	other threads:[~2011-01-06 18:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-06 16:08 Raghavendra D Prabhu
2011-01-06 18:22 ` Peter Stephenson [this message]
2011-01-06 18:51   ` Ricky Zhou
2011-01-06 19:54     ` Peter Stephenson
2011-01-06 20:23       ` Mikael Magnusson
2011-01-07 20:35       ` Phil Pennock
2011-01-08 20:10         ` 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=20110106182201.27da4de9@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.com \
    --cc=zsh-workers@zsh.org \
    /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).