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 4B424217EA for ; Wed, 10 Apr 2024 20:42:32 +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-Type:Subject:To:From:Date: References:In-Reply-To:Message-Id: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=JMcY/bQLU4gfvlTPjE1HsZKQlRqCangFe5llppEEKZM=; b=HZph/0xi9/5/xYfEnfDRLdbEN2 ngoH+voymZuxdwfKdgOCXpZUhqVSfueGIZ2b9ScChS2MC+CeO9X2Q5XUzGngHu4rpw2k+vnHbSsby UuUGQyt0p71NgQzcwmrWHdrefdDcR8GHS75rhLTIH/2SJk9OdKA8zUJYTiy45TXhOy+L8IOmRvTmr h4BugbYoJKr900rBHf4MbRvgGmk0kS7UmER/mZ35i/wLKgKrcx+UnmGnr8KvgCLy7nzrVEXp/H8fc Vpb1KMYHwLFcc05GG0idC+TkCA6KSVU1QCcM1YNAPlsA53SR0gVTNpVawP3siMUMyBibY6dvsPdXx jxXOkcHA==; Received: by zero.zsh.org with local id 1rucu0-000LZ7-Of; Wed, 10 Apr 2024 18:42:32 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1ructL-000KtL-BB; Wed, 10 Apr 2024 18:41:51 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfauth.nyi.internal (Postfix) with ESMTP id 418611200043 for ; Wed, 10 Apr 2024 14:41:49 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Wed, 10 Apr 2024 14:41:49 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesth dtredtreerjeenucfhrhhomhepnfgrfihrvghntggvucggvghljoiiqhhuvgiiuceolhgr rhhrhihvseiishhhrdhorhhgqeenucggtffrrghtthgvrhhnpeeileevheefgffhffeihe dtieegvdfgkeffteejgfetledtiedviedvteeukeegkeenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihvhdomhgvshhmthhprghuth hhphgvrhhsohhnrghlihhthidqudduhedukeejjedtgedqudduledvjeefkeehqdhlrghr rhihvheppeiishhhrdhorhhgsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 08A4C31A0065; Wed, 10 Apr 2024 14:41:48 -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: <0338833d-1414-4c34-8bea-793f45d4115a@app.fastmail.com> In-Reply-To: References: Date: Wed, 10 Apr 2024 14:39:45 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: zsh-users@zsh.org Subject: Re: color codes to eval Content-Type: text/plain X-Seq: 29787 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 12:46 PM, Ray Andrews wrote: > var="${red}howdy${nrm}" # '$(red}' is just a color code, no problem there. > print -l $var > eval "print -l $var" > > ... shows: > > howdy > (eval):1: bad pattern: ^[[31 > > ... Is there a way to feed color codes to eval? The issue is not "color codes" per se. It's the fact that (assuming ECMA-48 sequences) you're assembling and evaluating a command that contains a word with an unquoted, unpaired "[" character, which zsh deems to be an invalid glob (by default). It's no different from: % print a[b zsh: bad pattern: a[b > Seems to me I remember > that there's some ${(?) var} ... some flag in there that does it. There are a number of possible solutions. # Avoid the pointless eval in the first place. print -l $var # Delay all expansions. eval 'print -l $var' # Delay the problematic expansion only. eval "print -l \$var" # Delay learning how quoting actually works. eval "print -l ${(q)var}" # Leave invalid patterns in the command. unsetopt BAD_PATTERN eval "print -l $var" -- vq