diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2013-10-17 07:28:52 -0700 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2013-10-17 07:28:52 -0700 |
commit | ff520d1b798faa26037291e373689b5957784cc8 (patch) | |
tree | 10d802ac64e5ea5adcc58612208ed7d0b21e9314 /Src/hist.c | |
parent | 73ececfd01bc137366d25940d90a34aaa2cdb02e (diff) | |
download | zsh-ff520d1b798faa26037291e373689b5957784cc8.tar.gz zsh-ff520d1b798faa26037291e373689b5957784cc8.tar.xz zsh-ff520d1b798faa26037291e373689b5957784cc8.zip |
31823: add HISTORY_IGNORE parameter
HISTORY_IGNORE defines a pattern to exclude matching lines in the internal history from the HISTFILE at write time.
Diffstat (limited to 'Src/hist.c')
-rw-r--r-- | Src/hist.c | 17 |
1 files changed, 17 insertions, 0 deletions
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; |