From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id D612C20DD2 for ; Thu, 11 Apr 2024 02:03:02 +0200 (CEST) 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:Subject:To:From:Date:References:In-Reply-To:Message-Id: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=G5lMInZ30NrX1soP81qykS2KaGuAFQBH19oXxBa7eqg=; b=a3lU1RpoMpG64bV0ShvqBcvjUO ne/ASJLXcMfe5Dytv6LGkzqqODKVWTadfVoMX3DuuG66/MvwZ0xS07rLM6SGwJ00Pc+QR51i0sD9U TVXcQ16nMs/+yKNrzJF/jZBWUVOLG3otq1Jgrk31QPAhbLmCtC2CRsjg2Bcb1e4Y/nyPt1c6Ns0fV 9E89x2ne2z56aTIj/L4/+wLRlYq0+wr5FyiXjJsdIyVPFHGbxBPlK2gAuXZAZxlSDngHBel2+jRxv M8uF8gAIgYMEcraUI7MuEPbL74+Llt5poPfEefbluRuaSDlBXBFRAEOBYoYSolB8IBEluOeAAEsaK k7uJL8LA==; Received: by zero.zsh.org with local id 1ruhu9-0007xV-JG; Thu, 11 Apr 2024 00:03:01 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1ruhtV-0007Gp-67; Thu, 11 Apr 2024 00:02:22 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfauth.nyi.internal (Postfix) with ESMTP id 0EBE71200066 for ; Wed, 10 Apr 2024 20:02:19 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Wed, 10 Apr 2024 20:02:19 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehjedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepnfgrfihrvghntggvucggvghljoiiqhhuvgiiuceolhgr rhhrhihvseiishhhrdhorhhgqeenucggtffrrghtthgvrhhnpefgffeghfehjeegtdeitd evgeehgeehjeefffeffeefieeguedvtdegtdetudeufeenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihvhdomhgvshhmthhprghuth hhphgvrhhsohhnrghlihhthidqudduhedukeejjedtgedqudduledvjeefkeehqdhlrghr rhihvheppeiishhhrdhorhhgsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C6AD531A0065; Wed, 10 Apr 2024 20:02:18 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-379-gabd37849b7-fm-20240408.001-gabd37849 MIME-Version: 1.0 Message-Id: <02e80e14-471d-4084-9ba1-148aedd70443@app.fastmail.com> In-Reply-To: <47548b8e-a5e6-4fbb-8b57-4f3055f22c91@eastlink.ca> References: <0338833d-1414-4c34-8bea-793f45d4115a@app.fastmail.com> <47548b8e-a5e6-4fbb-8b57-4f3055f22c91@eastlink.ca> Date: Wed, 10 Apr 2024 20:01:37 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: zsh-users@zsh.org Subject: Re: color codes to eval Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 29791 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 Wed, Apr 10, 2024, at 3:12 PM, Ray Andrews wrote: > On 2024-04-10 11:39, Lawrence Vel=C3=A1zquez wrote: >> # Delay all expansions. >> eval 'print -l $var' > Works! And I believe I understand it. '$var' *will* expand even thou= gh it doesn't look like it, because eval takes a second crack at the lin= e after the single quotes are removed, yes? That's right. And since you're not using $~var or GLOB_SUBST, the result of that delayed expansion will be used literally instead of as a pattern for filename generation. >> # Delay learning how quoting actually works. >> eval "print -l ${(q)var}" > I'll play with that further, that's the thing I was trying to remember= . First efforts are not working, but I do recall that '(q)' ended up gi= ving me trouble down the line and was best avoided. If you can avoid it, you might as well. (Especially if you don't have a clear idea of what it does.) >> # Leave invalid patterns in the command. >> unsetopt BAD_PATTERN >> eval "print -l $var" > Looks dangerous! Looks like bad practice. It's usually not what you want, since it may let typos and other mistakes go by quietly. It's generally easy enough to handle troublesome non-patterns by quoting them or using them through variables. NO_BAD_PATTERN does align more closely with POSIX and other shells and is the behavior used in sh/ksh emulation. % script=3D'echo a[b' % bash -c $script a[b % dash -c $script a[b % ksh -c $script a[b % mksh -c $script a[b % yash -c $script a[b % zsh -c $script zsh:1: bad pattern: a[b % zsh +o BAD_PATTERN -c $script a[b --=20 vq