[Tcsh] Discard ~/.history when it grows over reasonable size

David Kaspar [Dee'Kej] dkaspar at redhat.com
Mon Aug 27 07:54:28 EDT 2018


On Fri, Aug 24, 2018 at 5:29 PM Christos Zoulas <christos at zoulas.com> wrote:

> On Aug 24,  2:19pm, dkaspar at redhat.com ("David Kaspar [Dee'Kej]") wrote:
> -- Subject: [Tcsh] Discard ~/.history when it grows over reasonable size
>
>
> I think you want to catch it earlier (while appending characters):
>
> diff --git a/sh.lex.c b/sh.lex.c
> index fee790a..091410e 100644
> --- a/sh.lex.c
> +++ b/sh.lex.c
> @@ -1522,6 +1522,8 @@ reread:
>             onelflg--;
>      } while (c == 0);
>      Strbuf_append1(&histline, c);
> +    if (histline.len >= INBUFSIZE)
> +       return CHAR_ERR;
>      return (c);
>  }
>
> I have actually tried similar approach before, but it didn't work. And
unfortunately, this also leads to to tcsh eating all of the memory and
triggering OOM killer... :-/

I would like to tell you why is that, but I haven't fully understood yet
how the lexical analyzer of tcsh work.

So far, only the patch I have sent you works (partially).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.astron.com/pipermail/tcsh/attachments/20180827/b5c86529/attachment.html>


More information about the Tcsh mailing list