zsh-workers
 help / color / mirror / code / Atom feed
* 2.6b13 history question
@ 1996-02-17 22:35 Jeff Blank
  1996-02-19  9:12 ` P.Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Blank @ 1996-02-17 22:35 UTC (permalink / raw)
  To: zsh-workers

I recently began using zsh 2.6b13 (up from 2.5.03), and I noticed that
there are some differences in the way history is handled...for example,
ls  -l ChangeLog
ls -l  ChangeLog
ls -l ChangeLog 
               ^space
ls -l ChangeLog
               ^no space
(etc...) all show up as separate history entries due to varying amounts of
space (even with histingoredups set).  I even produced the last two with

% ls -l Change<tab>  # supplies the trailing space
% !!                 # omits the trailing space, causing second history entry

Do these examples indicate some sort of bug, or is this a new inteded
behaviour?

Jeff
-- 
"I stayed up all night playing     // Jeff Blank      ***      MTU IT-Telcom
 poker with Tarot cards.  I got a  \\           jfblank@mtu.edu
 full house and four people died." // http://pace1.cts.mtu.edu:8080/~jfblank
                   --Steven Wright


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6b13 history question
  1996-02-17 22:35 2.6b13 history question Jeff Blank
@ 1996-02-19  9:12 ` P.Stephenson
  1996-02-19 17:57   ` Zefram
  1996-02-20 19:41   ` Wayne Davison
  0 siblings, 2 replies; 5+ messages in thread
From: P.Stephenson @ 1996-02-19  9:12 UTC (permalink / raw)
  To: Jeff Blank; +Cc: Zsh hackers list

jfblank@mtu.edu wrote:

> there are some differences in the way history is handled...for example,
> ls  -l ChangeLog
> ls -l  ChangeLog
> ls -l ChangeLog 
>                ^space
> ls -l ChangeLog
>                ^no space
> (etc...) all show up as separate history entries due to varying amounts of
> space (even with histingoredups set).

This is deliberate --- or at least known.  The shell now always stores the
line literally, instead of a pruned-down version with words separated
by a special token.  I didn't think it worth adding any code to change
this, since if you're repeating the last line I supposed you wouldn't
need to change the spaces.

If this seems important, the comparison can be changed to ignore
space.  This will do it, though perhaps someone else can think of a
less verbose way.


*** hist.c.ign	Mon Jan 15 17:10:25 1996
--- hist.c	Mon Feb 19 10:06:59 1996
***************
*** 537,542 ****
--- 537,570 ----
	histremmed = 1;
  }
  
+ /* compare line, ignoring multiple white space for HIST_IGNORE_DUPS */
+ 
+ /**/
+ int
+ strspacecmp(char *s1, char *s2)
+ {
+   /* ignore initial blanks */
+   int blankflag = 1;
+ 
+   for (; *s1 && *s2; s1++, s2++)
+     if ((iblank(*s1) && iblank(*s2)) || blankflag) {
+       while (iblank(*s1))
+	s1++;
+       while (iblank(*s2))
+	s2++;
+       blankflag--;
+     } else if (*s1 != *s2)
+       return (int)*s2 - (int)*s1;
+ 
+   /* ignore trailing blanks when one string has already terminated */
+   while (iblank(*s1))
+     s1++;
+   while (iblank(*s2))
+     s2++;
+ 
+   return (int)*s2 - (int)*s1;
+ }
+ 
  /* say we're done using the history mechanism */
  
  /**/
***************
*** 567,573 ****
		save = 0;
	he = gethistent(curhist - 1);
	if (!*chline || !strcmp(chline, "\n") ||
!	    (isset(HISTIGNOREDUPS) && he->text && !strcmp(he->text, chline)) ||
	    (isset(HISTIGNORESPACE) && spaceflag))
	    save = 0;
      }
--- 595,602 ----
		save = 0;
	he = gethistent(curhist - 1);
	if (!*chline || !strcmp(chline, "\n") ||
!	    (isset(HISTIGNOREDUPS) && he->text &&
!	     !strspacecmp(he->text, chline)) ||
	    (isset(HISTIGNORESPACE) && spaceflag))
	    save = 0;
      }

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6b13 history question
  1996-02-19  9:12 ` P.Stephenson
@ 1996-02-19 17:57   ` Zefram
  1996-02-20 19:41   ` Wayne Davison
  1 sibling, 0 replies; 5+ messages in thread
From: Zefram @ 1996-02-19 17:57 UTC (permalink / raw)
  To: P.Stephenson; +Cc: jfblank, zsh-workers

>If this seems important, the comparison can be changed to ignore
>space.  This will do it, though perhaps someone else can think of a
>less verbose way.

But your patch won't distinguish between `echo "  "` and `echo " "`.

Oh, try this:

$ echo \<space>          # N.B. magic-space is broken here
$ !!<tab>

compare with

$ echo \<space>
$ !!<ret>

-zefram


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6b13 history question
  1996-02-19  9:12 ` P.Stephenson
  1996-02-19 17:57   ` Zefram
@ 1996-02-20 19:41   ` Wayne Davison
  1996-02-21  8:34     ` Bas V. de Bakker
  1 sibling, 1 reply; 5+ messages in thread
From: Wayne Davison @ 1996-02-20 19:41 UTC (permalink / raw)
  To: Zsh hackers list

P.Stephenson@swansea.ac.uk writes:
> This is deliberate --- or at least known.  The shell now always stores the
> line literally, instead of a pruned-down version with words separated
> by a special token.

While I like the lack of added spaces, I don't like the fact that
hist_ignore_space doesn't strip (non essential) double and trailing
spaces.  I would like to see this option restored.

..wayne..


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6b13 history question
  1996-02-20 19:41   ` Wayne Davison
@ 1996-02-21  8:34     ` Bas V. de Bakker
  0 siblings, 0 replies; 5+ messages in thread
From: Bas V. de Bakker @ 1996-02-21  8:34 UTC (permalink / raw)
  To: zsh-workers

Wayne Davison <wayne@soprano.clari.net> writes:

> While I like the lack of added spaces, I don't like the fact that
> hist_ignore_space doesn't strip (non essential) double and trailing
> spaces.  I would like to see this option restored.

It never did such a thing.  The hist_ignore_space option makes
commands lines starting with a space not appear in the history list.
It did and still does.  The fact that those spaces you mention were
removed had nothing to do with this option.

Bas.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1996-02-21  8:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-02-17 22:35 2.6b13 history question Jeff Blank
1996-02-19  9:12 ` P.Stephenson
1996-02-19 17:57   ` Zefram
1996-02-20 19:41   ` Wayne Davison
1996-02-21  8:34     ` Bas V. de Bakker

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).