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,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19642 invoked from network); 24 May 2022 18:59:40 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 May 2022 18:59:40 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653418780; b=OeVMBoGXezu9yL6XvkqTm5un/5Em2DAn5ZqmUGk8dWShrbYnMEHTRBEdMT6vGhRHP0Hh+E4xOM 18smJpDJ68qeIblLdYsHOUgJ2JuP+PRiXKKUloAXyLCpMps3jy19wsSHXw3cIxzdPV6n4Xa10a UE6ZwIASjzABfLbtAHba2nUvMvm+ERYTHtcQlsc0VwzZfGZ7TtzZTXbN/w9ttnPUCJbTwRZlTe cMAFnYW1Q+h9qP7XZoD9+bzRpmEst9uvb8FUNRtHC4E6M6qWLKyw1sTDJ7bJKtqTCdyHgZ+E0/ ybBZISe9xMOSpQ7TkMQd+2iq0gtK9+DpgL2Vu250B9Pvqg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f54.google.com) smtp.remote-ip=209.85.218.54; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 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=1653418780; bh=mhtlo1KhycD+cPOHper7JsPicMVnZrhYVlLO/xGqj+Q=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=an4509gaIBPiGdUgSuGeIz6pMhSaMeoUGK4F6eoWpump6GCPZAJ8XkdQrASaEzFPna/4oYBPJ4 pFGpuoXl64j3nTZAZ3ul7+Gqv8XLPWrGnx7h6uHlTxTfIQ3F7454LAeIfqevBc4aliiaSLN/tC ZbykDw20FFh1qDF/42rPVhYjHoN+I9sjg4ec6cqQr4YVmh8xYS3V9fsq36xuhwhTw1R8GvOk9a MPNl1sERggi9weHqTQakChIXdUQFBmWDJBAdobh2xH4G3phHXepY4afrutU9uwpPbjp1u5GN8l SJtgP77p/dhPxUD/skfQ5KkmnLV6PcfUSM7k49QoiA9WDw==; 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:In-Reply-To:References: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; bh=ljS8EyeOdndEOhX9YxWOn0wKa8AWSRsSJEhZioS5w0Q=; b=pmjm3JiKGu2+Hfk2ZjHivXSnuh ALGo7y6xJyHYqt6/wjBfcr/4GwVR8mqz7YeTgvURyHdu4cCUTO0EKgMD2c70x6xnjim85AMxTFp1B qlOzv8p22zOdQ6hkzsK0SBqnhnvqy/o31OdeOMkYes6qhZE727JCFDjG552zobcENCf/UPW0UOlLr PShfhb64kbhN+zHoQ7C+06/AlZhkHo5/sl72zfzZkrgIfyDJ0AT7jblx/uIWIaKhFvgH6drEePY3Q 1yTGieuNqy/PoyAkLC2ST8ZfvQuzgoNNNnENEQpoTswF0TXCNxni7MJpRv39FZPn+EUWKLVWtN708 jGfOHYcw==; Received: from authenticated user by zero.zsh.org with local id 1ntZkp-00012s-7D; Tue, 24 May 2022 18:59:39 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f54.google.com) smtp.remote-ip=209.85.218.54; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f54.google.com ([209.85.218.54]:43807) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ntZjU-0000CW-9A; Tue, 24 May 2022 18:58:17 +0000 Received: by mail-ej1-f54.google.com with SMTP id m20so37191501ejj.10 for ; Tue, 24 May 2022 11:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=ljS8EyeOdndEOhX9YxWOn0wKa8AWSRsSJEhZioS5w0Q=; b=NE/PIHeIJjfWAvuNwAWoZw9UWu1wbm0tkOo20QJFwShuYrRJLwOgWPgYwMIDEODeNb T9HuU6IkgjyRS8pNXAq3FkPm1ETcc9F9tMj2RV412lG7Bp1Z3XCdkgOwqaKcV5euxn7g kGQZqpMnz0/l9ME3BFyIfyE4Dk74G26qsMaW3TdRnXL0XhLj8lC21omx9r3ILZ5dNPPJ S2ooHh43VZFszGi7xKxASrQmyqWg44FHrYFBtRRR7UySRu109UIZ2NUHrGTYRZvZKkha Rjy00Zt23zNbopEMW2urBhJClRuMkbvra7kj+bmyXwviYrDcf/RyZ+mlpMQRFQAkuukm 6XZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=ljS8EyeOdndEOhX9YxWOn0wKa8AWSRsSJEhZioS5w0Q=; b=q5dkp5fFr4q+h0Yz0W5iBHNYE2OQzMLbdHL4yiTzEYyx2ah3fLL+ZCHcQAGnuCn2XE 67DGs76Go4yLO9izhZNpZXFZagNRfW146jxk5M98lbzdy1WQYxy6lC6+lwZT5i3N1TQp jSnHsKLj3Cc+Eb99IG4Akv3AES8FVhK0y2qaKDRfr9B2kvpH+8azCnwuE/u8f1S6Wo42 rF4HlzoqogEaNU14urm7QsSTukDdOWXA1kFnwAK8zXVpOMVknFZgYYJLxZemgLLW1mtZ Wo6J7YesZ7F6NX/k5A+lyW7wj4RpwMBR7Omai/VufpdorcBkPZhkQI7SqZZxJTZ5zAhb lfyg== X-Gm-Message-State: AOAM533PrqA6ssit0ZboiKUVIo72PWDbPM3PG4pjfKQImlNWrbGf5RWr +66wp/Nqpn5MMm0OHvg7W+vTUXbWv1Y+/yAk3IppgMG8bp5Yzw== X-Google-Smtp-Source: ABdhPJwLlT6EvsvqoTnM+wAQzwBHoxMyFV6GL2oWZWShhrYwOs550eYgMoFXQvZv2p1iMMB9lRrY+v6SkGZ31LXpf6Y= X-Received: by 2002:a17:907:728f:b0:6f4:5d2d:38c8 with SMTP id dt15-20020a170907728f00b006f45d2d38c8mr25185976ejc.345.1653418695749; Tue, 24 May 2022 11:58:15 -0700 (PDT) MIME-Version: 1.0 References: <20220524154738.GA35284@cventin.lip.ens-lyon.fr> In-Reply-To: <20220524154738.GA35284@cventin.lip.ens-lyon.fr> From: Bart Schaefer Date: Tue, 24 May 2022 11:58:04 -0700 Message-ID: Subject: Re: prevent some lines directly coming from the history from being executed To: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27797 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 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? > 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.