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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24420 invoked from network); 8 Sep 2021 21:20:48 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Sep 2021 21:20:48 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1631136048; b=Ia0iS+wGVfv9WjG/c7zCKZ2kmOFbhDHJHDa9SaR486XgIbjmSpyDEDMCgnFceqq2HWqZIs/9hN KPI8JhyiXEHGKkvfBHoRnO70byRzS+D8vtCyeCVe0cWo/ZnZBFLkK0Enn8z7dUgKrVud8ok1B8 BFrI8wfJ4afiAEUsHPHOTZZ3pONho4dio+AcZ4FhuUc9Z7bVVuk0oMfkmmR55qmOqQFzCqBFxZ RldilsbCEQHA7nncwsZF3L8w4hH+324pH1IgDufW18+RF39qi9QkgrHvQwFVt63F7GmOTsiSx6 iqervkcxcsNsKw/zCDSJTI9P3xkRhhsZBTE/FEDUq+EN6w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1631136048; bh=CyCoIzi1CMnBSLrzZZEu9d/pNae34CVJ7ssqdvCy1Kk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=ezYjlZi7oT2aP9wnol2sthb6lLvw0EfdifCTDOYp6M8LSKXaORbxfwwZ7impEUB3KpIwHaAiki J9csIe9F903M1QRA3jc8P9LCmovMgAkaweb38pG4F369OVibjlYvl0H415ZhFLIB0RADsDvF0A KQ1/geqKTL4ED1vZIWBubePtEP+IDDQSDBRaWCjf5FBIhZYRVwuVyxp77EFGU6hGRGAjBO+94c 6R5WWbmDs79o81wXpQykYExgj/w42AKmQVDuy7T3dvINJDK/DYQsF8l6P4A8KDaqyJ8y71+A7L vDxsOFv5Gk3Ej4iBTbB8yIRvaXhsHMCOio8s6uNlCaApYg==; 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-Type:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=JdC4Fq+6WvOKCSUqMKGlvxNR0kTNG1tbNL1HgRGDlDg=; b=NEZpBhsUume/lA1Gdr/SIV+dat KB6U+HVQMpngZ9K2mICq0Y2KNkp5N6Zanb70ZmNBWaxN34Y3pxroYmkwSv+MjgyD9r/W4i+wpPMp+ pTvqrmIksBNRtJwsVYbqzry0IwRVA//mLnWz47sKLTdtR66v4DE3wR+730lqc2+ChAi1coF7e8pRV VthX+rDtZKtZxKPeeqc1zZ+K8eiLLjeOyLaDGWa0GO88Rvcr5treL2td9OFNk58ZrXNNsBonGQ8c3 s10PCM+mNQJyhrEabSU1M81YXcN4+8V3o2hqTmx7R63STGeKx5U7N+1I8dCzAm4qBPi1+aJEUE1OT naIWqZAg==; Received: from authenticated user by zero.zsh.org with local id 1mO4zu-000NjX-J7; Wed, 08 Sep 2021 21:20:46 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f174.google.com ([209.85.219.174]:38450) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mO4zN-000NQo-1o; Wed, 08 Sep 2021 21:20:14 +0000 Received: by mail-yb1-f174.google.com with SMTP id v10so7067282ybm.5 for ; Wed, 08 Sep 2021 14:20:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=JdC4Fq+6WvOKCSUqMKGlvxNR0kTNG1tbNL1HgRGDlDg=; b=o/NMgIxPFQeZrdbS2Fe4ppieaRvqYNma2HEHu1D2MR7NbrbQ08y8QqIUjTyzPw3p93 8CWJOsrJA6zFMTJtP7khZ7XL7c7CoPIrK8RAdqSS5xJLWCky/1y01/C7aMQEggv5qQVL 38lelwCDmlifur7z/dmRpIoolHzaZOt0kvh6qGpQzb0lrdBqBmGECimgpH++VqzcOYeg xZ3z5Qs2OBdBvPM72U1ylnH8E/8QBPMLSKnX+FcIOp06arPkNhzFmpDhMALSkbWluOPJ jBpyLOA5vPQzcYdv4tq2zWSjSzafBJzD4xSKrVGEgH9K04maLj66afEVM7GlbXmq+tr7 qAwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=JdC4Fq+6WvOKCSUqMKGlvxNR0kTNG1tbNL1HgRGDlDg=; b=NUm5Gjpv/DKT7rZ32LuP4ZHJhc2OlbtTg9zwbOLRthdcnx8VHTKaQwaNQQSJd2UE56 WlHIvvPz3Fhl7ii9obL2dYf4Wo4U0xAS7Rac+V+clzpXkx8g61Bzz/IIS0U6hOmpt8+j 1ns51XoS5KFuf12U5MjqzZfEEyCcZY+ceIT8SuNCDUU+Fa+V3IEaKyI4NoRoA+josbDM jle5uwNL/GrbCcyh5RowFnEZFMJGIMpb3KgQRy7pEqOgqDwUXrTkYQXp6/+bdKtcuoLK f6aZTf12nB7Zo0dfGtxRrc1O1vsvF7ckdxiJ4/oXvkuXFmGuN1qh8QX6hPZn+BeSmn9m 6ahA== X-Gm-Message-State: AOAM531OlDODnZ8nZ/124y6tF9RFicZqaPtxVa+pfcDH2zrHE1wyniPk x6Els0ZiDqf6CC80Wov9AguoTU7cioHMrLyrpytvuQs7P3OoNA== X-Google-Smtp-Source: ABdhPJxjjDsmOkzT2zMeFKM+9bDrWf7D+EyCRdPi81xp9avYBQrGazhWll976N+vMLf+DbSc6/6zYngiwAekb1rPliQ= X-Received: by 2002:a05:6902:150c:: with SMTP id q12mr449347ybu.410.1631136010801; Wed, 08 Sep 2021 14:20:10 -0700 (PDT) MIME-Version: 1.0 From: Bart Schaefer Date: Wed, 8 Sep 2021 14:20:00 -0700 Message-ID: Subject: Bug with handling of SAVEHIST? To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49400 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: The doc for "fc" says: 'fc -R' reads the history from the given file, 'fc -W' writes the history out to the given file, and 'fc -A' appends the history out to the given file. If no filename is specified, the $HISTFILE is assumed. If the -I option is added to -R, only those events that are not already contained within the internal history list are added. If the -I option is added to -A or -W, only those events that are new since last incremental append/write to the history file are appended/written. In any case, the created file will have no more than $SAVEHIST entries. That implies that: % SAVEHIST=0; fc -W should truncate the file, but in fact it does not, because savehistfile() is over-optimized to a no-op when savehistsiz==0. (I assume this is intended to prevent accidentally clobbering the history on logout.) However, this also doesn't work: % SAVEHIST=1; fc -W The entire current in-memory shell history is always written to the file when ((SAVEHIST > 0)). Digging in, savehistfile() pays attention to savehistsiz only when the HFILE_FAST bit is passed, and bin_fc() never uses that bit; it is used only by hbegin() and hend() to handle incremental history, and even then savehistsiz is only compared in order to disable HFILE_FAST again if too many incremental updates have been done. There seems to be an assumption that SAVEHIST will never be smaller than HISTSIZE, and as far as I can tell this has been the case for as far back as there are git revisions to look through ... despite the documentation explicitly discussing that scenario for added safety when using HIST_EXPIRE_DUPS_FIRST. Am I missing something? Is this just something we should correct in the documentation?