From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id B7268221E6 for ; Thu, 14 Mar 2024 05:53:17 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1710391997; b=WNOLf7ewuanKJayVE9h0bs1z8N0qrZnnrJK4FHTW9jnpZzlwst+ErT7eOOqswlRQ6soBDXSmOq tjq0cpeZICW8IPiyBaRMcTyj6DY9q1ADjzWDxrxefrRHQCcpjZFkvHIFQOzePTI6nhuiVHBFJE iYnu6NV4Da8y+ZFRZu5w5sU1IAkiflVG+6zA7+pbqrmuqzZq3ZqLZbQtqb/j/cS04dNWnwMaic 31ZUzyRQUvt8/exlAY73rD8ijALFH2u7mbWSkDNtckTJvtO49+Lvzjt+dJkz2z+KHrK9c4w2s5 m34WTG7L+mMiX7ci7IpR3lql1iZB2LI8P3ahdOa7skOluQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f53.google.com) smtp.remote-ip=209.85.167.53; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 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=1710391997; bh=3I3kLrKpB7T5Uksy77Jsn7ZgjlfMS0KbPsOr5LP3ehg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=UbKLvld7NJpwb5kmbMZwIxP+HzBeSW92dYxM7czV6nOR32ZFuqEgC7f5JznlU35L+2IOiWOHiq TqnhwuzPZrOtmR/7EeD+umdaJF8+KdO74koW6IyfTUXqyP+FrfvUl5nHWZ2LGE7FowjVhfQW++ /BWtTnVRDSn2hYWNPgaGOvwetJG5ELKSzJR3Vl/++wMNJPIH7DA/BAge5rMwYejmvIqROWih3u ZQeYRf2HJo4xT9l+pB1hocy0y3xT91/rnhVtXeJBuc5fuC6UMQW9sF5QQA2+OT6E+h9FICM6GE UtcCkVqei4B3Jxm3GemP29ilvIao2cS72s+5t68ViCx5vQ==; 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: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nn2vCvPPRSkVbVqk0LITuDT3Pac/a6L1pvmGwI14hCw=; b=Hg/TLP541P7MD4LpmXHm+C9t5O F6ScjQVNIpcCj7W+TACwJDBUjYX4fxRaGgz8v+mFOnGHXOLcYIFKSxAzL8foRFpiCXZn5z3r2xUgE 5cKoikiWw1Y6dWtk3gwqUQ59L1nUF0MClOmbyyToDQFZePwo8ahg4HlqmcwJot7MgGrl2Rx8StlOR F7fIWx/G+MPXsnY93DS+mZRlUiYkZyxVBSZu0vHit02d+SZkOb9ae7PlpFHFYirmdQYe+nWmLxiDI 7DzEe35XcU/viGsTHDeD9hccwvroXzWzSu0cXAu2q1u7pU5dV1M6V8tsLspbGbF9b6DMqYSKWr85Y TdssuM4g==; Received: by zero.zsh.org with local id 1rkd5f-0009Ke-Q8; Thu, 14 Mar 2024 04:53:16 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f53.google.com) smtp.remote-ip=209.85.167.53; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-lf1-f53.google.com ([209.85.167.53]:58824) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rkd5M-00092b-VU; Thu, 14 Mar 2024 04:52:58 +0000 Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-513af1a29b1so678144e87.1 for ; Wed, 13 Mar 2024 21:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1710391976; x=1710996776; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nn2vCvPPRSkVbVqk0LITuDT3Pac/a6L1pvmGwI14hCw=; b=K3+Y5C+wRV1YX+28RfdotK600LbgscctCaotsHDWXLYrxDpTqftYe2hlngCu/SYxK6 m99VHx+nHd7P4gniWNrhRP3EoxmvcbHEWVbUEE70XuUxj7VDMs4fbOfyP3/SWkCJuhUJ R5oMwOmG+4d27XobmBf40hk9VOc2NK17mhz//u1zdazUU76Kw5hi0ESV+NNqgIsPMHM3 gDf9LV23VexYHVNUWG1oruez3mBX0g1sVmawurlCmvJr6wnzlPcrnuE4N7BdCJsaEpGg B5F7quabKAZOD1S9H4n5b3hEwqVDejnjmmeYFfVMWJSi3I473EW8c8M+6zGEhJd+75Hu Wxdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710391976; x=1710996776; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nn2vCvPPRSkVbVqk0LITuDT3Pac/a6L1pvmGwI14hCw=; b=gAd6X3AkVUD58fqe5lCR/Dsh4KrkCTekTp7G2pQbDYNAfkXDrjeAVNgViOf+t3CYm4 P82BdR0wXHaDJnYKl5A93GoD/nXtZi+wBmDNZhBrqwl22rysds9ZRc30W26a/AJH6SCQ NN5Ce8MPD72ReIzRnKGLMPdzH4fTQmDUyjIFDdZ6PsUVReCqz4kfPrBYVCWpurax2Ja5 G7KDx6sq+/PqqSTexUiNnARTVyHENdhJRUBgFP1KzZAxIFDuObZ8ZRUSJCoSUy6xfcwb QrlLsJWEsbDTSZ6axx306yoSBTqi6IsmWHxzXXwSP8E6JB/i7Prh8k7bcVwtDkRZfx9x nOsw== X-Gm-Message-State: AOJu0YxaTzva6qrSlGM9gsKsmejmMEqbtQd5NYJI12AtcU+bgT0e/uIf HR16D8ynpcTBZSFgcfJtidD4PIjTn6Gt4riligQulrGHXYf7jmVzAtCdrV8f857s1i0oHbCslFg emkBcClhZbg9CuKTg8uHaElWhAJSVCJ4bMyyRA6eoD9LTc5AqYg== X-Google-Smtp-Source: AGHT+IGFthZCIDfRuc2B8tFZbuVkzeiADbgO2RTHGrWmtlAFHu00pGNrlucBVIQmSg0/dOaKzLyiWMrDw+Z/Hh+Qm8M= X-Received: by 2002:a05:6512:3687:b0:513:c9f5:cbf2 with SMTP id d7-20020a056512368700b00513c9f5cbf2mr321732lfs.59.1710391975900; Wed, 13 Mar 2024 21:52:55 -0700 (PDT) MIME-Version: 1.0 References: <20240313150511.GA3498572@cventin.lip.ens-lyon.fr> In-Reply-To: <20240313150511.GA3498572@cventin.lip.ens-lyon.fr> From: Bart Schaefer Date: Wed, 13 Mar 2024 21:52:44 -0700 Message-ID: Subject: Re: issues with saving history to file To: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52754 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: On Wed, Mar 13, 2024 at 8:05=E2=80=AFAM Vincent Lefevre wrote: > > With zsh 5.9: > > cventin:~> zsh -f [set up history parameters and options] > cventin% exit > cventin:~> ls ~/.histfile > ls: cannot access '/home/vlefevre/.histfile': No such file or directory > > However, if I use INC_APPEND_HISTORY instead of APPEND_HISTORY, the > history is saved. This is because history is being incrementally saved (as the option name indicates) rather than being held only in memory until the shell is preparing to exit. APPEND_HISTORY just means that if the history is saved, it will be added to the history file (up to $SAVEHIST) instead of overwriting it. > According to the zsh(1) man page: > > Note also that the RCS option affects the saving of history files, > i.e. if RCS is unset when the shell exits, no history file will be > saved. > > But the difference between INC_APPEND_HISTORY and APPEND_HISTORY is > not documented concerning this point. Congratulations, you've found another place where documentation of feature X was not updated upon the introduction of newer feature Y. The doc for history is littered with these because it's been around longer than just about anything: HISTFILE is still documented as only being used at shell exit. Someone else can patch it this time. > Also, I do not see the point of not saving the history when RCS is set. It is saving when RCS is set, and not when RCS is not set (no_RCs). This is done because of the handling of $SAVEHIST, not to mention the various duplicate handling options. When no_RCs, the history has (presumably) not been read in at startup in the first place, so it won't have been merged with the interactive state. If written out when never read in, the $SAVEHIST size limit could cause contents to be lost that otherwise would not be. (Frobbing the RCs option during later shell operation is effectively undefined behavior, too difficult to keep track of.) > IMHO, HISTFILE should just be unset by default; but if the user sets > this parameter, I suppose that the goal is to save the history. The goal might be to read the history, not to write it. In any case we've had several go-rounds on this (and on the "right way" to set HISTSIZE vs. SAVEHIST) without coming to any consensus differing from the existing behavior. > Without INC_APPEND_HISTORY, the man page doesn't document when > precisely the history is saved. For instance, what happens if one > has a "print -s ..." in the .zlogout file? It'd expect it to be lost, because the history is saved before .zlogout is read. Try it and let us know. Maybe it dumps core. > Moreover, with INC_APPEND_HISTORY, "print -s" does not put the entry > in the history file immediately, only after the next accept-line. "print -s" doesn't write to the HISTFILE and isn't documented that way. It explicitly says "Place the results in the history list". The "history list" is the internal shell history, not the file. The file is updated from the internal list either at shell exit or (incappendhistory) when a line is entered (i.e., conceptually upon accept-line, though in practice upon entering a complete command since updating at PS2 would leave an incomplete entry). You can use the zshaddhistory hook to confirm this.