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

Re: HIST_IGNORE_DUPS also ignores command lines that differ by a space between quotes



On 2024-03-19 12:08:26 +0100, Mikael Magnusson wrote:
> in hist.c:
>     if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && save > 0
>      && hist_ring && histstrcmp(chline, hist_ring->node.nam) == 0) {
>         /* This history entry compares the same as the previous.
>          * In case minor changes were made, we overwrite the
>          * previous one with the current one.  This also gets the
>          * timestamp right.  Perhaps, preserve the HIST_OLD flag.
>          */
>         he = hist_ring;
>         newflags |= he->node.flags & HIST_OLD; /* Avoid re-saving */
>         freehistdata(he, 0);
>         curline.histnum = curhist;
> 
> and in hashtable.c (weird place for it):
> /* Compare two strings with normalized white-space */

It is placed in hashtable.c perhaps because of its use for cmpnodes
in this file:

    histtab->cmpnodes    = histstrcmp;

But is this correct?

> /**/
> int
> histstrcmp(const char *str1, const char *str2)
[...]

> seems you could simply replace histstrcmp with strcmp and be happy.

Thanks. This now works as expected.

BTW, without this change, the following commands are regarded as
the same for HIST_IGNORE_DUPS, while they are very different:

qaa:~> printf "%s\n" a\ b
a b
qaa:~> printf "%s\n" a\  b
a 
b

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




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