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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 27462 invoked from network); 22 Aug 2022 14:01:52 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Aug 2022 14:01:52 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1661176913; b=RdxUmTaODa9YYUEiRSJmUtSdh/AsfaRbwAJwBZf5xRYCqzAZhe6V/bzETXWV8K3qAShltR+PAU hk8NsfOpXEaP0MZe1A4R//moX1P/ilbpJxOWDjeQ/JQb9U6LNYkAt6/9QehQFGOIJOfdU6BN4L K7qck90KqtUU346a+Xa2RFpvCmSsA7PtOAUUceb51uGk+4DtcPaORhDMdtzyzoYImnn9lx7hap +h1vuNsHwx2Y1ZQSPL3jSp+6P1+C+0jcfqq4UcmVoWqQONi29yziJDlCcsld1wCaZ8rYdHXlDI LyYWBU7+L2+KU7tfyOZ596sxQ8lHEVaYxy2A3jT9hKTv3w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1661176913; bh=Qs+BGiAocXO1g+AKlfRkqb2lCHNSLrx/oecF+jVASGA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=ftm4DB9PI2ksWUMackf4rPFsyBqRY0sGESXox0zTnrSh+FNLPNQJMbOS9sXgWVUjIZRoZd7MYh 9plFnde4q5mhhCKJGeSOsq8zpxcWMcdt99Edo9AEjwy5jJJdwrz+37S7TKAI3gZ1JVR+vUHHJm DSfYDTWZ6WyqyMaFx2g+GeBVRoQ77wdFNw/5GD9Gs3nuYPZS+3GvTG0/nzAd9dIvat678Fx5DS AIzjBSm4ppDpOp1eseaofQwaD/cUwenuq9KuLP9pbe88Cw0WRuwG4dgKOtWj4N50g/0qY3eYMp nEUXIwRtlUIWJw92vtZQRg7To/M4OXjjOI9O2dj2Qt3x1A==; 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:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=UjUuIQ+xR1t2BAWRAWCbOYhqzU7ggHBKxnoSYxlZdOI=; b=sOHHCECpdbad22hviCHpqApz4s MyXfgV4m3nQApQh0mVJ7haE8S425vGruPKMEc6oiq3ekDVOGieRo7+c4DDuWtIBVt72LEO+gBZiNK lSbEjGlVLWJwrwQ8PAzpk8x+j4g8pdqQF14pcCC/qxLHpuGIX4PV2qXNQyjQYpA8cfYoCilJm6uqj oIRh7InDlamORiaLUok1H1wDXjRTimLlssT0xeLhY8Au49qcvftodyG9NwtZHxsJwCGWYRfKLUr9m 918O1jc2zi5sJtgIwGJg3IkeZHxvBYKx5f8L73qNx5ahaDQ0EpwOAHXnvecCciqHRwqipN7sIZY5z 6VyZU92Q==; Received: from authenticated user by zero.zsh.org with local id 1oQ800-000EMo-In; Mon, 22 Aug 2022 14:01:52 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:39974) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1oQ7zR-000DiQ-6p; Mon, 22 Aug 2022 14:01:17 +0000 Received: from [212.54.57.80] (helo=smtp1.tb.ukmail.iss.as9143.net) by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1) (envelope-from ) id 1oQ7zQ-000396-O3 for zsh-users@zsh.org; Mon, 22 Aug 2022 16:01:16 +0200 Received: from oxbe19.tb.ukmail.iss.as9143.net ([172.25.160.150]) by smtp1.tb.ukmail.iss.as9143.net with ESMTP id Q7zQoTgPGVu5XQ7zQoCbeQ; Mon, 22 Aug 2022 16:01:16 +0200 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-users@zsh.org X-SourceIP: 172.25.160.150 X-CNFS-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=63038c2c cx=a_exe a=5CzvcAr/sXcdrkwznnUi5w==:117 a=1DWFKdCB1IcA:10 a=IkcTkHD0fZMA:10 a=ZjyAdWuDOD4A:10 a=fOGFPsoFAAAA:8 a=mkrMv_ursDal2hE82CgA:9 a=QEXdDO2ut3YA:10 a=9uiqvtoqkUw5yu36GLfy:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1661176876; bh=Qs+BGiAocXO1g+AKlfRkqb2lCHNSLrx/oecF+jVASGA=; h=Date:From:To:In-Reply-To:References:Subject; b=HWGCdm/1JlQB/LcC49wKKjjOM/2ww1WjLFdoIYWEx4GOjLgGNHm92ZZr6dkdaW/tm w/4SA+p7ojxy22B8tqlfFrimDLjBIr0Q54RhMPttSmkVPe2LdWYuOXfRA2/kFajx4T tLNDmUyOe/87VusmZfcWVcxXELyPWH6y94eOkXw4ikaFahefGUoQvDi4ImhuJS8UDU hZeit1azyXFq/TmqhduZVBiYaXTGrl4TUCge2tKPNetAxNKLQTQRaWreFHa3z3g9vD PAEONHYLsrXnatLNaesHnhKY5IVmT10+rl6OG222ym3kEs4pUwgZeEx7FGppbI5GlU ZoiXXQhLRGv4Q== Date: Mon, 22 Aug 2022 15:01:16 +0100 (BST) From: Peter Stephenson To: Zsh Users Message-ID: <1591910550.1867255.1661176876454@mail.virginmedia.com> In-Reply-To: References: Subject: Re: Unexpected results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer X-Originating-IP: 147.161.224.167 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfL09bLkoBEw2GBVVnv9IioaGpgWrGmRHNSejcIctoNTUjzyJvEDwoP+uFTphF5qpY3Z8yseOBgIkF69KyZOhyS9tkBuLxAH9W+ukRFkgPAZiN+TOEfF6 Txwwlot5wvNxOPequswDrdYUB7VemW7XWvDMIrj5zZmAPJaiOTsNU+xnJgU4wSjgBXexsuyuE5UCP4ak+ScJEDlpec93Xh6VF9DfcoKhI1sirYJWpjKwoCom X-Seq: 27974 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 22/08/2022 14:16 Perry Smith wrote: > This was unexpected: > > % echo 'a/path with spaces/in/quotes' > a/path/in/quotes > % echo !:1:h > quote> > > I was expecting the equivalent of > > % echo 'a/path/in' The :h modifier on history is pretty brutal, yes. We store the full history word internally, but a "history word" is before the lexical analyser has got to work, i.e. the raw expression with quotes in it. What you want is that word after it's been processed internally. Unfortunately that's a bit of a mouthful... echo ${${(Q):-"!:1"}:h} This takes the whole of that history word inside a parameter expression (there's no parameter before the ":-" so zsh uses the value after), strips the quotes, and applies the :h flag to the result of that. Someone may have a neater method. You can get this as a ZLE widget; smart-insert-last-word has all the bits to extract the word itself --- though it's way over the top for the current purpose --- then all that's needed is the substitution above just before inserting it on the line --- except you'd want to re-quote it perhaps with a ${(q-)...} wrapper in that case. (Of course I understand the response is most likely to be "umph, forget it"...) pws