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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11409 invoked from network); 16 Apr 2023 15:53:59 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 Apr 2023 15:53:59 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1681660439; b=jjUso8USFcKwEu/KLNRCcn8CUPNp3c49KHAHM+aEyFzBQ/r2AJQWAfAnpScio7WUZgVtJDnlk4 a6rCYKOGp9n8iHQqqtplEeys9BTUXKmjTTvG3+pHCLkwPO1OmKMDrqYkai2i4aEkZYPC7JYAIl EvYdpu+64zVcr9jYqlDdCEf3JvHGmYN4uCFfeJACI+NeO6qxtnUYQKyahRNji3qpgblQKktF4V tp0GVY7inhKlpvZAOGAAGYJha0ESdv+FJnqxbJZt6UBhbH8hIROLWEGQYKaIyHbET5tziUnU++ Lhr3sCgQ+5jjF/ytiJKi9tco4aPNV03E0NycTPGJAomzdQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 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=1681660439; bh=0PzmAZjPUt566bNaY8BEJFX08YF/arvcy2zd48UQ1ns=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=VNACiwOr9oIVkFHhl1k3p421mHbyITNKB837066paC0cTIebgAx6C/PaJTa1TO1edhRWFg0wak pb7ROUAjh35XSG/M+CXF2iH6FrtrJe7M7JKdIrXqtO2aEzRZuvH7rO0ewao1eay25UAdeSURK+ cmai6atuYfj3IZPRPCuxk8l0qavOaWIZplQ/UvzFHi46ENZR0BLcJEPGSAlFv8dwfgOTOoWb3X 1lFLVTnWIuFuBiQ08o+M1axlqDkyfLZTgTC65rrwWyRpyBsEyEwRrtieX6UjRmXDL8NR/0UDGK pgGnahC2xCX1He4OlXjNSloud72hIvKnSbH53+mfmN5KUQ==; 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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=8hYHgB5NHXmn4k9s0fMmJX/o9E2582MTZ4m2nC/jsQI=; b=b0aGIq43+CsToidN9+TCCcN49V KTqot7jrDTwKGB4URXpf2xV7vyxDuFgPDBL4AOZx6pQXbktc9SrHXY8vDkYVhFSKz4DMFotZBfO1o 9bIPrqBnItoR43I/u75n82L4OdzXuM3W2hLCNKF18QKeRp8FDbRz/FifIWVPcz5AL2F+qqlli5kI3 kqs3hi0qPJrC0r3tK947ss4sWT+ohIQJNxiRawO0WnviSdIXZCxH7ZNp6iVOThU2YnhVjY90f30R7 Wu95obRJfjwiQZqczOwfqgnQOdcOO7jNzG8cFeqOj8ZoDCPoWIoE/fOx3qTStvagOnkz5o3PLfxef ERRLPO+g==; Received: by zero.zsh.org with local id 1po4hT-0008Xt-74; Sun, 16 Apr 2023 15:53:59 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f53.google.com ([209.85.218.53]:47029) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1po4go-0007qA-2y; Sun, 16 Apr 2023 15:53:18 +0000 Received: by mail-ej1-f53.google.com with SMTP id xi5so57990441ejb.13 for ; Sun, 16 Apr 2023 08:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20221208.gappssmtp.com; s=20221208; t=1681660397; x=1684252397; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8hYHgB5NHXmn4k9s0fMmJX/o9E2582MTZ4m2nC/jsQI=; b=0z1bDhF8cQNKx4TaHFyETVuletlO87vmrYnC4kmFRtC88Hc66t7IKMWNGH0E5RIGeq qtXuvpCDd+uNKrnGerUs4pKVHhZAt9TPWq0SDmDKsu2GENw/kWSlapYziZZbj7R0dlrv nC9hY+GfQGz2Ko73lqsn7wnGFgVLfp42jJbe8U9ZcFiaXz+UPQGWX00rLsDVR6scyuAb kNm4HrA8ogFhOiQKIGnyAQ44L0NTv1p2xnIuU6NoRpdWHtwwc9aaULKOwBXBGJ33hzYn Y7KuQ097D/Burr4ZltqJg+i7H5sJ3txApgkqGR1gTpVqIceHLbTQhxPORku1kBOPzmjx R5pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681660397; x=1684252397; h=content-transfer-encoding:cc: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=8hYHgB5NHXmn4k9s0fMmJX/o9E2582MTZ4m2nC/jsQI=; b=KR5PCmolYGZbN+yDNOd5DVUWJ0vEHCoJ/m3rPM/PBtt7mz7Te9IJmRLTABEQSLYbds mUYW3hWBd5Mu+Dn1wgJvt4YrzJH0ECxGCRFMmR10mAOBY6qoIX2a+ss3tN19gkQAk9UU 8YvqIaj0Qww+jcv0SIYBqAnDdICZSSqeQv6BTFFCwWta+67W5YeRs0p7Vb5sZopQpugE I33lefEBqtXQCZnYugRge44Ee6QEMmPDOFsfYvP8yDSPR45ya4DCWS3EJw6k9ItoIncY IbrduMWl0OPOZMzcGuLzKnov4ZcLsx+nQSG6+ovmyFNNhqhit3jM6kE7f4C9SCrN5Gb3 Z7aA== X-Gm-Message-State: AAQBX9eqPttSjA6F2ccVy8wsA89SmUM7i3LaHwDr4eA6Z9YEMwa4daVn xeptZMhQVgEhDgL2dWVmyebhKoPeHznxpmPoh0ogNg== X-Google-Smtp-Source: AKy350YmLhTbtKwbbwgbw7XMzlBKMRkgQzO4DJIPQ2aXF2llqgZjfPUUgxWYlRF/zDtc4mhLxYuqxjZz+Tbhnrtxla0= X-Received: by 2002:a17:907:3f0a:b0:94f:3eca:ab05 with SMTP id hq10-20020a1709073f0a00b0094f3ecaab05mr2973810ejc.59.1681660397661; Sun, 16 Apr 2023 08:53:17 -0700 (PDT) MIME-Version: 1.0 References: <81609CF4-42DA-4E0F-A6E5-C5D58578B4F7@easesoftware.com> <9a1f77ea-ee4e-95ff-a571-5cd3ddce6cb2@eastlink.ca> <8b0f0941-5212-5268-1f9d-d7542990439a@eastlink.ca> In-Reply-To: From: Bart Schaefer Date: Sun, 16 Apr 2023 08:53:06 -0700 Message-ID: Subject: Re: "Pull just the text of a single command" (was Re: .zsh_history) To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29032 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: [Bringing in other responses from the "was Re:" thread] On Sun, Apr 16, 2023 at 7:53=E2=80=AFAM Ray Andrews wrote: > > On 2023-04-16 00:38, Roman Perepelitsa wrote: > > On Sat, Apr 15, 2023 at 5:31=E2=80=AFPM Ray Andrews wrote: > >> $ my_function $path $(eval 'ls *') one two three ! < > ``.."" &>^! > >> > >> my tail, exactly as typed, is: $path $(eval 'ls *') one two three ! < = > > >> ``.."" &>^! > > What would this do? > > > > % list=3D(my_function arg) > > % $list > > > > What I typed is `$list`, but what is "tail"? > > > > Roman. > > I don't understand. You're assigning a variable no? Right, you don't understand. Roman's point is that % $list is going to run "my_function arg" as a command, so there's nothing in "its tail as raw keystrokes" that corresponds to what "my_function" will receive in its positional parameters. The assignment is just setting up the case of interest. If Roman had written % list=3D$(my_function arg) then your follow-up would be closer to the mark, because then my_function would actually run during the assignment instead of during the expansion of $list. > There's just that: "% echo one; echo two; echo> three" problem -- I'd lik= e the middle 'echo' to know that it's tail is > 'two' and nothing more or nothing less but of course recall from history > gives all three commands in one serving. It's much worse than that, consider % my_function one && my_function $PATH || my_function three > filename Or pipelines, or backgrounding, or if/then/else/fi, etc. You will need to define what you intend in each case (please, not by writing it in prose here). The ${(z)...} expansion does a best-case job of mimicking the parser, so you can start by using ${(z)1} in preexec and work forward from there. The simple case with semicolons can be handled by chain=3D( ${(s:; :)${(z)1}} )