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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, 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 210E923E7C for ; Wed, 10 Apr 2024 21:12:53 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1712776373; b=r4gN3gnON4i4FHdlW6e9dmN3YxsPNjmVbOxyMCMnfXcOjvcdQRt+8zD77nY78q2A1JOMaI1mbI xtJ7AeyQiU/mhFZb6yOqRvhecZ8k4fHHjg/viyv69rIHffYFy0gRod0cEIpWQ48B7QA5vWXnzN YJamHJd6Y5LyqH4VFy3vwZCfAqkzSIHsmuXaMkSu/VNC9staakZTmFYxVCr6E6ujOyLjIxoEAC 7v6515HL5HMVGoyuGHNRYAgXhz/SGxupbhAAA+wqnZE3BcZMQHx9eisciBoeBhhHQM0tT5oUI+ bzS6DwCgVvk4QsK0gJDloUZnLiqd9UR/TIMTTNEf1rkFcQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1712776373; bh=vPHMZdbBd3tcFGpKcnPqnfN8x36hjLseUokk2NWsnPE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature; b=V1qYGiz2m+z4ErT1pFmaEn5mTBNY7tk/OXsqp9zpkmFF3YMSG01SDi8fJKdqgU1d3zVeJovSUQ Jjz6ty//C3PGGrQSbAAasCd39cUFFVFw8RTc7eGFHr+CZgPI6Ryo5/gjhf2D+LDakKA5Qu6tjo XcZD60IQDOtxeTik5HnQq2d9FOLXP/oLjXA+FZ/lnejuEb7sx1KlUAIS1aKsEKSmQCVeAkacXe K8G7bop4K9o9ygf1K9GFpRKhkYqad9upE7DwzJ3eHNGN5UPA6VYw944U+xCJPlz4dBfRYVKWJc ehF/J3MwfeFft6XRAe+t4iuntgYNiiXyIft5jCEnMJYcnw==; 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:In-reply-to:From:References:To: Subject:MIME-version:Date:Message-id:Content-type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2cBmo/U5zKdx3JDP70on2GvwPcvHNAQSTAxYf1nKDno=; b=ZuraQLFQZ9QILllpQQ0U2SElyC 7xlf6tegWNhPv6RoI9/PWQqYP2IQ97htmLCsRDUf4j7vaxoThslCcdc4EusvQht+HzTt9JlMdRYRb USzd9HW7oL8r0C5GjvRF9fYmkd+Zs3AKM7RAPNm2eQMUt17j7JTbWe2W/Q2ZVua3w4kG//wncBMQV iPJVp01hxs48dPvIKMNK2LDe6P0K1DBLXfepATmvvZHfbZa6V5Ye7265J0RYPwbYghusxi2xxE313 lxXaTmfyQ4FgOY2TOtBH8EHTetGAdbti59g5hMasu7w4k07GbyEc/m8GOnqeSaG0TuG02bXeOlw5S bvf4XmmA==; Received: by zero.zsh.org with local id 1rudNN-000PA2-9M; Wed, 10 Apr 2024 19:12:53 +0000 Authentication-Results: zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none Received: from mta04.eastlink.ca ([24.224.136.10]:42695) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rudMd-000OLk-M9; Wed, 10 Apr 2024 19:12:09 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta04.eastlink.ca ([24.224.136.10]) with ESMTPS id <0SBQ26J65QK2QUW0@mta04.eastlink.ca> for zsh-users@zsh.org; Wed, 10 Apr 2024 16:12:06 -0300 (ADT) Received: from [192.168.0.11] (host-24-207-19-13.public.eastlink.ca [24.207.19.13]) by csp01.eastlink.ca ([71.7.199.166]) with ESMTPSA id udMbrcOA5AimnudMcrzgdS (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Wed, 10 Apr 2024 16:12:06 -0300 X-Authority-Analysis: v=2.4 cv=Q8Rx4J2a c=1 sm=1 tr=0 ts=6616e486 a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=e_kZ6DY2KIVM41fxvMUA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=ZLGELXoPAAAA:8 a=I6g2AlCc5GN42N4q708A:9 a=HZwiqYHDBM7yNMY0:21 a=_W_S_7VecoQA:10 a=CFiPc5v16LZhaT-MVE1c:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedgudefvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfgtefuvffnkffpmfdpqfgfvfenuceurghilhhouhhtmecufedttdenucenucfjughrpegtkfffgggfuffvfhfhjgesrgdtreertddvjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhephfettefhveeguedvleeggfdvvedufeeuudffvdfgledvvdfgtdeigeeuueelieefnecukfhppedvgedrvddtjedrudelrddufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvgedrvddtjedrudelrddufedphhgvlhhopegludelvddrudeikedrtddruddungdpmhgrihhlfhhrohhmpehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgdpnhgspghrtghpthhtohepvddprhgtphhtthhopeerredprhgtphhtthhopeiishhhqdhushgvrhhsseiishhhrdhorhhgpdhgvghtqdgkihhprfgrshhsfigupehtrhhuvg X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------np0jEPPxCUuQcCXC0DqMalqJ" Message-id: <47548b8e-a5e6-4fbb-8b57-4f3055f22c91@eastlink.ca> Date: Wed, 10 Apr 2024 12:12:04 -0700 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: color codes to eval To: zsh-users@zsh.org References: <0338833d-1414-4c34-8bea-793f45d4115a@app.fastmail.com> Content-language: en-US From: Ray Andrews In-reply-to: <0338833d-1414-4c34-8bea-793f45d4115a@app.fastmail.com> X-Seq: 29789 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: This is a multi-part message in MIME format. --------------np0jEPPxCUuQcCXC0DqMalqJ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-04-10 11:39, Lawrence Velázquez wrote: > # Avoid the pointless eval in the first place. > print -l $var The problem occurs in a deeper context where the eval can't be avoided, I just extracted the minimal example. > # Delay all expansions. > eval 'print -l $var' Works!  And I believe I understand it.  '$var' *will* expand even though it doesn't look like it, because eval takes a second crack at the line after the single quotes are removed, yes? > # 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 giving me trouble down the line and was best avoided.  As to learning, that's what I'm trying to do.  Coming from DOS, the rules there are very different -- there's no preprocessing by the shell, command tails are passed to commands exactly as they are written.  It takes time to unlearn that.  It's almost hard coded into my brain. > # Leave invalid patterns in the command. > unsetopt BAD_PATTERN > eval "print -l $var" Looks dangerous!  Looks like bad practice.  But I'll experiment with it. But:" # Delay all expansions. eval 'print -l $var' ... looks like the proper answer. Thanks Lawrence. --------------np0jEPPxCUuQcCXC0DqMalqJ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

On 2024-04-10 11:39, Lawrence Velázquez wrote:
# Avoid the pointless eval in the first place.
	print -l $var
The problem occurs in a deeper context where the eval can't be avoided, I just extracted the minimal example.
	# Delay all expansions.
	eval 'print -l $var'
Works!  And I believe I understand it.  '$var' *will* expand even though it doesn't look like it, because eval takes a second crack at the line after the single quotes are removed, yes?
	# 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 giving me trouble down the line and was best avoided.  As to learning, that's what I'm trying to do.  Coming from DOS, the rules there are very different -- there's no preprocessing by the shell, command tails are passed to commands exactly as they are written.  It takes time to unlearn that.  It's almost hard coded into my brain.
	# Leave invalid patterns in the command.
	unsetopt BAD_PATTERN
	eval "print -l $var"
Looks dangerous!  Looks like bad practice.  But I'll experiment with it. 

But:" # Delay all expansions. eval 'print -l $var' ... looks like the proper answer. Thanks Lawrence. --------------np0jEPPxCUuQcCXC0DqMalqJ--