zsh-workers
 help / color / mirror / code / Atom feed
From: martin.ebourne@arcordia.com
To: zsh-workers@sunsite.dk
Subject: Very odd behaviour with zsh, maybe corruption bug
Date: Thu, 11 Oct 2001 11:57:46 +0100	[thread overview]
Message-ID: <OFFE2ABA9E.2332FF4A-ON80256AE2.0038ACE5@uk.jpmorgan.com> (raw)


Hi,

Seeing Bart's suggestion to Oliver Kiddle about the use of
history-beginning-search-backward/up-line-or-history, I decided that was
nearly what I wanted, so decided to fiddle with it until it was exactly
what I wanted. Anyhow, it essentially works except that a condition which
should evaluate to true is sometimes returning false for no reason I can
figure.

I'm using zsh-4.1.0-dev-2, and I can reproduce this with zsh -f. It is
however not completely reproducible in that it appears to involve some kind
of random effect/corruption so it needs a few goes before it happens. I'm
using Zsh on:
SunOS gdd-odybin2 5.6 Generic_105181-28 sun4u sparc
SUNW,Ultra-Enterprise-10000

First extract this into a file:

=== START bizzarre.sh
_up_fn() {
  if [[ $LBUFFER == *$'\n'* ]]
  then
    _searching=''
    zle .up-line-or-history
  else
    _searching=$WIDGET
    zle .history-beginning-search-backward
  fi
}

_down_fn() {
  setopt local_options
  set -x
  if [[ ${LASTWIDGET} == ${_searching} ]]
  then
    _searching=$WIDGET
    zle .history-beginning-search-forward
  else
    if [[ $RBUFFER == *$'\n'* ]]
    then
      _searching=''
      zle .down-line-or-history
    else
      _searching=$WIDGET
      zle .history-beginning-search-forward
    fi
  fi
}

zle -N new-up _up_fn
zle -N new-down _down_fn

bindkey "^[[A" new-up
bindkey "^[[B" new-down
=== END

Then execute as here:

% zsh -f
gdd-odybin2% . ./bizzarre.sh
gdd-odybin2% "abc
dquote> def"
zsh: command not found: abc\ndef
gdd-odybin2%

Now if I type a single " and play around with using the four cursor keys
trying to use the history matching & down, after a couple of minutes I can
be pretty sure it will have gone wrong. (Sometimes I ctrl-c or press enter
and try again - don't know if that matters.) Once it has gone wrong it
appears to continually go wrong until the down function is re-defined
(that's the minimum it seems to need to 'reset' it). Due to the 'set -x'
you'll get a messed up screen display, but just try and ignore that!

The 'gone wrong' is where the following line returns false even though both
variables are the same (you can see because of the 'set -x' I added - this
was only added for debugging, and isn't needed to make it go wrong).
--->  if [[ ${LASTWIDGET} == ${_searching} ]]

Here is an example trace where it has gone wrong (once the bug had been
'activated' I just pressed up followed by down to get this):

gdd-odybin2% +_down_fn:3> [[ new-up == new-up ]]
+_down_fn:8> [[ "abc
def" == *
* ]]
+_down_fn:10> _searching=
+_down_fn:11> zle .down-line-or-history

gdd-odybin2%

As far as I can analyse these variables they are exactly the same, as it
appears in the listing, and this first condition should return true, but is
actually giving false. Please tell me if I'm doing something obviously
stupid, its by far the easist solution. ;)

Cheers,

Martin.




This e-mail message is CONFIDENTIAL and may contain legally privileged
information.  If you are not the intended recipient you should not  read,
copy, distribute, disclose or otherwise use the information in this e-mail.
Please also telephone or fax us immediately and delete the message from
your system.  E-mail may be susceptible to data corruption, interception
and unauthorised amendment, and we do not accept liability for any such
corruption, interception or amendment or the consequences thereof.


             reply	other threads:[~2001-10-11 11:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-11 10:57 martin.ebourne [this message]
2001-10-11 16:30 ` Bart Schaefer
2001-10-12  5:02 ` Bart Schaefer
2001-10-14 21:56   ` PATCH: " Bart Schaefer
2001-10-15 11:24     ` Sven Wischnowsky
2001-10-11 17:09 martin.ebourne
2001-10-12  9:19 martin.ebourne

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=OFFE2ABA9E.2332FF4A-ON80256AE2.0038ACE5@uk.jpmorgan.com \
    --to=martin.ebourne@arcordia.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).