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, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14500 invoked from network); 11 Feb 2021 19:49:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2021 19:49:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1613072950; b=S2DgQ2pHcLhX9lJaKiluqfOIHHMODTr3NTueXx1FI3Z4qxBnuW66bfFQV5LZBZmtTW0q7lifgv WLpgEqyd58y29prNBVGWyrGYzD5JDfI9v3ekpdBvqquZQGN3Ht4Wyf4mITtnjC3Ci65QQEJZKC vFm2MMcoxktl20+z4xi9q1CHiOlfSHAr3knyk4TpW4KtqBeuUAuAF1M61ZlFZnq0hvPUmkZaL1 +mCECD904jMGAXNWCne3Och66BV/KDuIAjxNBCxF62DFM3kFC7Ijirsj75+du9QsPL4pdb+vLJ aZJmEBij7hjD3PhatbbT7W6WnLqiiMuDZDLB90w2z2DIPg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1613072950; bh=x7+TG0XPoDjQjCgX54ORzz4url2IvRHLSiSDbB2rvpA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:To:Subject:DKIM-Signature; b=WIfHVPkYRRaVLsqH7aK1BOpFgK5FCDC7uFAzmIBoCXj+G7GNT2jRycss2LI86sbbyh6lOZmXR9 eMkYGUBA7lN7Mdgt6tgtmZ8w3CXHZ81QeiHzVsL8SAJU5mnrlVdBytXPPkyYEDqzLtX8UqRyJV 2x87Zv1qyPxthYxRddEpss3fFE4Yn8ixcTfevSnCRoykK5F6DaSEebviTqt4D11bBV2bWgWiXo m+e+1ZHRJ6edhq68nYN+P0ELJ38opUv2a0AJ3LVaji5dxVe494SkCZY0Irh7+otnlK9kSxP4Ax f3KT36epG/hVWiguor/dS7iQ67mR/bz/beGKmpQKxLi/bA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-transfer-encoding: Content-type:In-reply-to:MIME-version:Date:Message-id:From:References:To: Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=LAu/C9Ui5qzfRW/rR4CLpim9sXZsiKwT70YRsa6oq+U=; b=nHSsJXC78s5XqZemwSmweauOwZ zNRl69+2fMOPAM97l4+hHbbeeeFXRT3F3HHGdsRkddFUZ3oW/Bv7N0/vHbYHkmmUCj6yt1bVFkju/ 7nZUgkr4ijoY/gk2Lqygkd6RrrtND90YL+aJUSdbjF5I0lkUYDM9No9pOT5aYSRdyM2HQjTI+Mliv gcuD1JEQvO7BCESTJHFNpCTxaD5f/a9oDweGtmjwzrXR4jmdd/wDJOzrnIEAiu0caDEINhnF/g8sg WJDIObGvhddb807XBX7gR0EQIf9xFU1K45EkrnM6BJTAosOYcwjF1nrgOg40Wh164bHS7SLktg7xS F9IxJYeA==; Received: from authenticated user by zero.zsh.org with local id 1lAHxc-000BG6-LS; Thu, 11 Feb 2021 19:49:08 +0000 Authentication-Results: zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none Received: from mta02.eastlink.ca ([24.224.136.13]:44780) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1lAHx8-000AtE-2m; Thu, 11 Feb 2021 19:48:38 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta02.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0QOD00K3IQZ84FR1@mta02.eastlink.ca> for zsh-users@zsh.org; Thu, 11 Feb 2021 15:48:36 -0400 (AST) Received: from [192.168.0.3] ([24.207.90.194]) by Eastlink with ESMTP id AHx5lX9eEnkRCAHx6lakFN; Thu, 11 Feb 2021 15:48:36 -0400 X-Authority-Analysis: v=2.4 cv=B+J8bMhM c=1 sm=1 tr=0 ts=60258a14 a=zv49KfEsxEDzuN5AGO7r0Q==:117 a=zv49KfEsxEDzuN5AGO7r0Q==:17 a=IkcTkHD0fZMA:10 a=E_FW_CqM3B5QAyzmEwMA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrheelgdduvdekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepkedvueeuffefhfdvueeiteffvddtvdejgeeujeekieduheeiteeiheegtedvhfefnecukfhppedvgedrvddtjedrledtrdduleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdeltddrudelgedphhgvlhhopegludelvddrudeikedrtddrfegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-IP-NOAUTH: 24.207.90.194 Subject: Re: protect spaces and/or globs To: zsh-users@zsh.org References: <52D5DA56-397F-40BB-BBA7-CE3BF7256581@larryv.me> <29a203d5-bf53-9cb7-7a49-2705c3b1d8f2@eastlink.ca> <87a6sc3d0c.fsf@lwm.klanderman.net> <752329601.3729797.1612972051119@mail2.virginmedia.com> <379883051.3731455.1612974540761@mail2.virginmedia.com> <8a718224-f0e4-d960-1d65-f600ec818415@eastlink.ca> <544A50D4-7F71-4763-8DEC-D5D99E4AE7CC@larryv.me> From: Ray Andrews Message-id: <0d053511-25cf-4d4e-7f57-1823c915fec3@eastlink.ca> Date: Thu, 11 Feb 2021 11:48:35 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-version: 1.0 In-reply-to: <544A50D4-7F71-4763-8DEC-D5D99E4AE7CC@larryv.me> Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 8bit Content-language: en-US X-Seq: 26508 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: Archived-At: On 2021-02-11 9:19 a.m., Lawrence Velázquez wrote: > > Why are you still accreting grepargs like this? Peter has already > shown you how to do this. > > grepargs=("$@") > > Unless your actual code actually modifies the args before adding > them to the array? Not modified but the ordering is different so I hafta grab them one at a time. Good point tho, all else equal I see that Peter's method is better. > [...] > > % pat='on the current' foo='i,2,light edit' bar='i,1,old stable' > % grep_wrapper $pat $foo $bar > > what should be going to history: > grep --color=always -i -- 'on the current' 'i,2,light edit' 'i,1,old stable' Yes, point made.  I know that if I want something expanded I don't single quote it. But indeed I shouldn't say 'exactly as typed' because I know that variables will be expanded. > [...] > > A ${(q-)foo} expansion basically re-quotes the value of foo so > it works correctly with eval, in whatever way is requested. It > doesn't know the value's origins. That's a subtle but important point.  I could think of it as 'protection' but then how did the variable expand?  As you say it must be seen as re-quoting.  Thanks for catching it. > That's not how quoting works. Quote levels don't nest to produce > some kind of super-quoting. You're misinterpreting the results of > your experimentation. > > % foo='a b c' > % print -r 'protected: $foo' > protected: $foo > % print -r "'not protected: $foo'" > 'not protected: a b c' > > The double quotes do protect the single quotes from being interpreted > by the shell, but they also permit expansions. That is a critical point.  You know, it is so easy to think you've 'got it' when you don't. I'm going to take the above and write it to a sticky note a stick it to my desk.  Very insightful of you to realize that I'm not seeing things right, many thanks.