--- Src/builtin.c 1 Oct 2004 18:51:44 -0000 1.127 +++ Src/builtin.c 1 Oct 2004 19:12:23 -0000 @@ -1340,7 +1340,7 @@ bin_fc(char *nam, char **argv, Options o zwarnnam("fc", "too many arguments", NULL, 0); return 1; } - return !saveandpophiststack(-1); + return !saveandpophiststack(-1, HFILE_USE_OPTIONS); } /* with the -m option, the first argument is taken * * as a pattern that history lines have to match */ @@ -4111,8 +4111,11 @@ zexit(int val, int from_where) } if (isset(RCS) && interact) { if (!nohistsave) { - saveandpophiststack(1); - savehistfile(NULL, 1, HFILE_USE_OPTIONS); + int writeflags = HFILE_USE_OPTIONS; + if (from_where == 1) + writeflags |= HFILE_NO_REWRITE; + saveandpophiststack(1, writeflags); + savehistfile(NULL, 1, writeflags); } if (islogin && !subsh) { sourcehome(".zlogout"); --- Src/hist.c 9 Sep 2004 10:12:47 -0000 1.53 +++ Src/hist.c 1 Oct 2004 19:12:24 -0000 @@ -2093,7 +2093,8 @@ savehistfile(char *fn, int err, int writ } fclose(out); - if ((writeflags & (HFILE_SKIPOLD | HFILE_FAST)) == HFILE_SKIPOLD) { + if (writeflags & HFILE_SKIPOLD + && !(writeflags & (HFILE_FAST | HFILE_NO_REWRITE))) { int remember_histactive = histactive; /* Zeroing histactive avoids unnecessary munging of curline. */ @@ -2445,7 +2446,7 @@ pophiststack(void) /**/ int -saveandpophiststack(int pop_through) +saveandpophiststack(int pop_through, int writeflags) { if (pop_through <= 0) { pop_through += histsave_stack_pos + 1; @@ -2459,7 +2460,7 @@ saveandpophiststack(int pop_through) return 0; do { if (!nohistsave) - savehistfile(NULL, 1, HFILE_USE_OPTIONS); + savehistfile(NULL, 1, writeflags); pophiststack(); } while (histsave_stack_pos >= pop_through); return 1; --- Src/params.c 1 Oct 2004 19:06:49 -0000 1.91 +++ Src/params.c 1 Oct 2004 19:12:24 -0000 @@ -3611,7 +3611,8 @@ mod_export void endparamscope(void) { locallevel--; - saveandpophiststack(0); /* Pops anything from a higher locallevel */ + /* This pops anything from a higher locallevel */ + saveandpophiststack(0, HFILE_USE_OPTIONS); scanhashtable(paramtab, 0, 0, 0, scanendscope, 0); } --- Src/zsh.h 9 Sep 2004 10:12:47 -0000 1.60 +++ Src/zsh.h 1 Oct 2004 19:10:59 -0000 1.62 @@ -1365,6 +1365,7 @@ struct histent { #define HFILE_SKIPDUPS 0x0004 #define HFILE_SKIPFOREIGN 0x0008 #define HFILE_FAST 0x0010 +#define HFILE_NO_REWRITE 0x0020 #define HFILE_USE_OPTIONS 0x8000 /******************************************/