From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22539 invoked from network); 24 Aug 2022 04:38:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Aug 2022 04:38:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1661315899; b=dQ2Zi1mIyYWx1bZUtBTPGNMlutU+eIn6naKjvB6F1iigB9qpZAcd49YwG9oNT0vPBAETCzE/lr 46LyfTgXUYHfLiYSXFSCkMX5ujN9q8r8bnb+rnFj2fkyU/kNTSxSN4BLb/gno9GkleCbDmuka7 wWrvjOCZW3ArKcPgQhe5gqpAM9AydwdkFQ3+GTVVkH5hTuw+WsVxuZZm9A5nx/0z/1Pk3q9+Yg G+/SSSw0DCmZo4BIcUM+I9BjRHKM3nsxvQe5463Mf6ArGabLKOpdb0oObSZ/rXxu7DZckVrrDA dCCj2zOfoMz5dFJRiAy681M/7ubFqs34PGnNaMiUsLwxbg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f45.google.com) smtp.remote-ip=209.85.210.45; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1661315899; bh=ULrqTUVx6onqHj7PlgD8ENEk5krMXDF5bb2y4pI2w50=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:DKIM-Signature: DKIM-Signature; b=OTtvqtZ5heGF513alnx03hhzYorKSeHlcaOV35iOI/DAf3eD1AyOID9FG/Njz/y3TRjOcH8yRq sMAT+Ld3QF6InL3BcSUC2hzve7k3NMfwhN757qU2pMh4eBOveLOEHHvSiFyU798oZ5lR3DpUZ7 ZPCj6zF/N/RD5y31IFIDCi2Zc2I9iOChgq6sjUbCw8rEgW4Za9Ri8K6YIs+OmvWt5JQ1W1By9l U7RlNbeZtC8hm3rTbVkTMXpRpdf1c5AhDZAxc9kE8AjiSxW6RWI5d0UqVKkVC9sKkqn2O3WTcS yg2ldHqiR0Y2yt2K5PBEybc4+YLm3UKzJ4/2frynxoNYPQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=8tTvyBOv/rPFYIGWgqMzo/LJkR91oemqDzj43bMBk/s=; b=SdTUyAT1t2b4KgS0gKGkHHiesr 07JTs2yDoE6UN7gksRbhGTLt/WgM2jXcKr9bd/+x7x0+CjhzddRRWzPtneiazzCJaVODykbfaa3iT letvuYvb3VUGZLgDWle+/W3nWB3f3jjtgryvtzYGXPEAr6a3fOB+lQvlr8hnYWlE19FgnEwOKbEVX vDJ9eu9jAsg53TH5doDwRRzrrysQqZAPwgSPmfS+BfzkjIrFhSkIA/+vVCSmNV7if25ZObL0OK4Rb wXf/ndU59YTctLuDcIHGUCtxUCAW/tzVVR6rxiH7+88Q92SYgd9XdbMqz5UvZY34dlUcTf3t3yXiw 5WIWMjIg==; Received: from authenticated user by zero.zsh.org with local id 1oQi9j-000Dnr-2h; Wed, 24 Aug 2022 04:38:19 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f45.google.com) smtp.remote-ip=209.85.210.45; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ot1-f45.google.com ([209.85.210.45]:39597) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oQi3T-000Cnb-BU; Wed, 24 Aug 2022 04:31:51 +0000 Received: by mail-ot1-f45.google.com with SMTP id br15-20020a056830390f00b0061c9d73b8bdso11094000otb.6 for ; Tue, 23 Aug 2022 21:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=8tTvyBOv/rPFYIGWgqMzo/LJkR91oemqDzj43bMBk/s=; b=XVc7COdBa5aKl2qNRUHbCAPzNk/eYabPe6cN6xVk+myemFL2WhBTaC+1j4NCgP+L8B zn7aau37/IxhM5JdS+k1BCFYY7D06oybGFDX1avXCbmb2JgeXhQ/I4RySNDWo9VVs3an KMjMxBsgNjEPlEEWk6x14TLHq12eZfgiypaHRQWRllrEbrO3PiAcVGmSmXHLdYDCmmv0 gTosMP/O9bBJA4eTIMo7y26XI8p2y6BIi76pw9SxIQso+AE12KBRf5/aWs8OJOuwCOXk xw2ES98PCJfz9qWRH2kNpZHX/Wg4qXP8j/bNBqKnMk8DexAiuv2VYJ2HE1vvo6TXwwed NErw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=8tTvyBOv/rPFYIGWgqMzo/LJkR91oemqDzj43bMBk/s=; b=r45RchkBuuch0Qqaxs1E6ZaZDv0hLULIlnHzqQmSUzXTOQIp9qrqpuUGthPRv6sNVH rfyWpM94gg8gbrDaeWExoamW8kki7i8RqhVvlh/2smvePsfcsP7yKaF3+0N5y88D0MG0 2Du425ZMoxzIOqntfSiGTG7QXyegZBMbkmmWvexi4nHvXxrMdid8Ehmc5XpC5UvA34a8 xfN/8/73UPAOYRcHQHrbsAXxUO9wH0bdxE0TacF8qN9+5zoRQg/SWlta8o1JZjV4fzGj wdyuY5/G9VFEOXT1K/BveqMS+5PwGCpu3W8J1Sm1nLGS2QETIoBzy1fTraDthRAYe8H9 1ieA== X-Gm-Message-State: ACgBeo25YKrarsr/+Re5oZnqS38srkm6ODpZasjWegqW7BI5lTaurpgT wmmIow53Q+guJJ2aAq1LSudAhnslsZo= X-Google-Smtp-Source: AA6agR5dqs8j1xKx9okC51xmm1G7JCkTwVuvKtttR1IyIUzy6Cow4hHj37UMmvPCDjQHmou1TuBKSg== X-Received: by 2002:a9d:3646:0:b0:618:fe0f:8f68 with SMTP id w64-20020a9d3646000000b00618fe0f8f68mr9967080otb.57.1661315510037; Tue, 23 Aug 2022 21:31:50 -0700 (PDT) Received: from localhost ([2806:2f0:4000:94d:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id m9-20020a056870560900b0010e3cb4c98fsm4355445oao.9.2022.08.23.21.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 21:31:49 -0700 (PDT) From: Felipe Contreras To: zsh-workers@zsh.org Cc: Felipe Contreras Subject: [RFC PATCH 1/3] Make SAVEHIST default to HISTSIZE Date: Tue, 23 Aug 2022 23:31:43 -0500 Message-Id: <20220824043145.165779-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220824043145.165779-1-felipe.contreras@gmail.com> References: <20220824043145.165779-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 50500 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Signed-off-by: Felipe Contreras --- 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