Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[RFC PATCH 1/3] Make SAVEHIST default to HISTSIZE
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
Etc/FAQ.yo | 10 +++-------
Functions/Newuser/zsh-newuser-install | 1 -
Src/builtin.c | 2 +-
Src/hist.c | 14 ++++++++++----
Src/init.c | 1 +
5 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index 8c795685a..a334dd384 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -1626,19 +1626,15 @@ work?)
sect(Why is my history not being saved?)
label(321)
- In zsh, you need to set three variables to make sure your history is
+ In zsh, you need to set two variables to make sure your history is
written out when the shell exits. For example,
verb(
HISTSIZE=200
HISTFILE=~/.zsh_history
- SAVEHIST=200
)
tt($HISTSIZE) tells the shell how many lines to keep internally,
- tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
- the easiest one to forget, tells it how many to write out. The
- simplest possibility is to set it to the same as tt($HISTSIZE) as
- above. There are also various options affecting history; see the
- manual.
+ tt($HISTFILE) tells it where to write the history. There are also various
+ options affecting history; see the manual.
sect(How do I get a variable's value to be evaluated as another variable?)
diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install
index 9e911d07c..26fcaed77 100644
--- a/Functions/Newuser/zsh-newuser-install
+++ b/Functions/Newuser/zsh-newuser-install
@@ -792,7 +792,6 @@ __zni_history_config() {
__zni_apply_defaults -p \
HISTSIZE 1000 "Number of lines of history kept within the shell." \
HISTFILE $zdmsg/.histfile "File where history is saved." \
- SAVEHIST 1000 "Number of lines of history to save to \$HISTFILE."
if __zni_display_and_edit "History configuration"; then
install_state[history]="Unsaved changes"
diff --git a/Src/builtin.c b/Src/builtin.c
index a7b7755a7..4c928d9bf 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1442,7 +1442,7 @@ bin_fc(char *nam, char **argv, Options ops, int func)
if (OPT_ISSET(ops,'p')) {
char *hf = "";
zlong hs = DEFAULT_HISTSIZE;
- zlong shs = 0;
+ zlong shs = hs;
int level = OPT_ISSET(ops,'a') ? locallevel : -1;
if (*argv) {
hf = *argv++;
diff --git a/Src/hist.c b/Src/hist.c
index bff0abe61..6cc612724 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -238,6 +238,12 @@ static zlong histfile_linect;
/* save history context */
+static inline zlong
+get_savehistsiz(void)
+{
+ return savehistsiz < 0 ? histsiz : savehistsiz;
+}
+
/**/
void
hist_context_save(struct hist_stack *hs, int toplevel)
@@ -1348,7 +1354,7 @@ putoldhistentryontop(short keep_going)
if (isset(HISTEXPIREDUPSFIRST) && !(he->node.flags & HIST_DUP)) {
static zlong max_unique_ct = 0;
if (!keep_going)
- max_unique_ct = savehistsiz;
+ max_unique_ct = get_savehistsiz();
do {
if (max_unique_ct-- <= 0 || he == hist_ring) {
max_unique_ct = 0;
@@ -2904,7 +2910,7 @@ savehistfile(char *fn, int err, int writeflags)
int extended_history = isset(EXTENDEDHISTORY);
int ret;
- if (!interact || savehistsiz <= 0 || !hist_ring
+ if (!interact || savehistsiz == 0 || !hist_ring
|| (!fn && !(fn = getsparam("HISTFILE"))))
return;
if (writeflags & HFILE_FAST) {
@@ -2915,7 +2921,7 @@ savehistfile(char *fn, int err, int writeflags)
}
if (!he || lockhistfile(fn, 0))
return;
- if (histfile_linect > savehistsiz + savehistsiz / 5)
+ if (histfile_linect > get_savehistsiz() + get_savehistsiz() / 5)
writeflags &= ~HFILE_FAST;
}
else {
@@ -3086,7 +3092,7 @@ savehistfile(char *fn, int err, int writeflags)
/* Zeroing histactive avoids unnecessary munging of curline. */
histactive = 0;
/* The NULL leaves HISTFILE alone, preserving fn's value. */
- pushhiststack(NULL, savehistsiz, savehistsiz, -1);
+ pushhiststack(NULL, get_savehistsiz(), savehistsiz, -1);
hist_ignore_all_dups |= isset(HISTSAVENODUPS);
readhistfile(fn, err, 0);
diff --git a/Src/init.c b/Src/init.c
index 871d46b12..8a95192a9 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -962,6 +962,7 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
noeval = 0;
curhist = 0;
histsiz = DEFAULT_HISTSIZE;
+ savehistsiz = -1;
inithist();
cmdstack = (unsigned char *) zalloc(CMDSTACKSZ);
--
2.37.2.351.g9bf691b78c.dirty
Messages sorted by:
Reverse Date,
Date,
Thread,
Author