From ff520d1b798faa26037291e373689b5957784cc8 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Thu, 17 Oct 2013 07:28:52 -0700 Subject: 31823: add HISTORY_IGNORE parameter HISTORY_IGNORE defines a pattern to exclude matching lines in the internal history from the HISTFILE at write time. --- Src/hist.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Src') diff --git a/Src/hist.c b/Src/hist.c index fa5bdbb3c..1845bd8ad 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2600,12 +2600,27 @@ savehistfile(char *fn, int err, int writeflags) } } if (out) { + char *history_ignore; + Patprog histpat = NULL; + + pushheap(); + + if ((history_ignore = getsparam("HISTORY_IGNORE")) != NULL) { + tokenize(history_ignore = dupstring(history_ignore)); + remnulargs(history_ignore); + histpat = patcompile(history_ignore, 0, NULL); + } + ret = 0; for (; he && he->histnum <= xcurhist; he = down_histent(he)) { if ((writeflags & HFILE_SKIPDUPS && he->node.flags & HIST_DUP) || (writeflags & HFILE_SKIPFOREIGN && he->node.flags & HIST_FOREIGN) || he->node.flags & HIST_TMPSTORE) continue; + if (histpat && + pattry(histpat, metafy(he->node.nam, -1, META_HEAPDUP))) { + continue; + } if (writeflags & HFILE_SKIPOLD) { if (he->node.flags & (HIST_OLD|HIST_NOWRITE)) continue; @@ -2685,6 +2700,8 @@ savehistfile(char *fn, int err, int writeflags) histactive = remember_histactive; } } + + popheap(); } else ret = -1; -- cgit 1.4.1