Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 2.6b13 history question



jfblank@xxxxxxx 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@xxxxxx>       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.



Messages sorted by: Reverse Date, Date, Thread, Author