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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13793 invoked from network); 25 May 2022 02:54:59 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 May 2022 02:54:59 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653447299; b=czWC6rIHCl1MjIgGdlEd+uARh+k1Vg3RQAdR72grv+xVySYEGCV11CYf1Rcj7kPHD6xF4jEQnv clEc1WiTX5llDHeYx83MxMocrNghvKtIYGKxAF1oD7+vo4H9LzjHK6xDrZ5JjN6TXkpegfm8jW XQOcJkIPWDCDbKgcIOKb05g7pW5g2zQcvGP8ZpKO46ncowpXioW6ugoegc27+KxWAcYbrl/SvL IgIOlCzPk7QDBGdgS7H/+CKXEybFxV58ci58iYV8Xj7gmd5T88ep/XAScxr48g2yesIjtlss1g H5ziqCq++kbUkC+aJf1wHF/8pyUeTa9ytuuTTwlrg8s1pw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1653447299; bh=Xc70kAXZ7XzHCSrTGhxiWXtC7kiYrDlPc7p0tIgm3aU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=q7EyDYsKl4ie4RDc2PeVxmhk4IGneef1g19ggeXSHum24wqXT57t86ssdadXyVSgD2p/JPTY0T wNleSuUlM19zk3zp8bFoqZybV/lgXi9GAagpx7baCT0PvtCkGXrv4dbyAjwIHAASeEl2MWWmOY vWWau4XPTvGAXczUVbTZAMeRFCYxzhaHZerG++KT/lKGHS9ccx2dF0HViw5ixBXxdNdvOU5JSY p/QcnRY/Cj1hK+jP+Z6/ClGaT+gDWPd7C2t1vBequmahrTedZAyAWflo/GA1ru8k4jYMUv0qyO IwdCwHWvPWsQ0m+AWY27j67WhLsqYrjFnoui3p1i8F9oXg==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ItVxswVLnaQdfzvCHDq9do4XB+AynlmrczR7QrK71nM=; b=fQjz1d5xsRV+yz/FdG7PQCu2Pc t7Uei0GY50ndvdVmvN/RgNpjQkZYEx7WfG3PmEqDyjPfhKy0s32x4hizRx/KY+Z1A5HAs/rhTPTnC 22iRWFMAC1LRp14jGzWPhK830UcjfYJ3DMscr0Zuk9iRyiG3ZNEQtXaJx2CMKuBVqY433/Q9+bOMv 0tQzrgqbQQ2G9D1eM+UdD8Vn/xWypbPxZOSFfK0YIHA8DEpsh+BB+J4FAXlxQPN9sK7EfzRDkCAMk ZG+LcMc7BPgTYzq/+dpzgO0VAOIH0VpMhc7WpJUmd8PKaUpJFZMAA5WJW0H2nNmOyMSJW+F7HdwgB 8c2uPgfA==; Received: from authenticated user by zero.zsh.org with local id 1nthAo-000EqZ-2l; Wed, 25 May 2022 02:54:58 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:33350) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nth9w-000E5l-Sx; Wed, 25 May 2022 02:54:05 +0000 Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128]) by joooj.vinc17.net (Postfix) with ESMTPSA id E2A5324F; Wed, 25 May 2022 04:54:03 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id A1AC02800226; Wed, 25 May 2022 04:54:03 +0200 (CEST) Date: Wed, 25 May 2022 04:54:03 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: prevent some lines directly coming from the history from being executed Message-ID: <20220525025403.GA97860@zira.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <20220524154738.GA35284@cventin.lip.ens-lyon.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.2.5+22 (1066be97) vl-138565 (2022-05-21) X-Seq: 27798 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 2022-05-24 11:58:04 -0700, Bart Schaefer wrote: > On Tue, May 24, 2022 at 8:47 AM Vincent Lefevre wrote: > > > > Some lines coming from the history may be "dangerous", in the sense > > that one may not want to executed them by mistake (e.g. for lines > > recalled with a quick Ctrl-R ... [Return]). > > > > Is there some mechanism to prevent such lines from being executed if > > they were not modified after recalling them from the history? > > The first question is, how do you identify those lines? Pattern match? Yes. > > something like a hook that would inspect such lines and return 0 or 1, > > depending on what one wants to do. > > You can add something to zle-line-finish() that compares > [[ $BUFFER = ${history[$HISTNO]} ]] > along with whatever your other criteria are. This will always be > false for a new command line, and I believe should always be true for > an unedited line retrieved from history, but might need tweaking for > multi-line constructs. This doesn't seem to work. I've added [[ $BUFFER = ${history[$HISTNO]} ]] at the end (thus currently catching all unmodified lines), but this doesn't change anything. Is the exit status of the function really taken into account to prevent the execution? -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)