zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: color codes to eval
Date: Wed, 10 Apr 2024 12:12:04 -0700	[thread overview]
Message-ID: <47548b8e-a5e6-4fbb-8b57-4f3055f22c91@eastlink.ca> (raw)
In-Reply-To: <0338833d-1414-4c34-8bea-793f45d4115a@app.fastmail.com>

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]



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.

[-- Attachment #2: Type: text/html, Size: 2379 bytes --]

  parent reply	other threads:[~2024-04-10 19:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 16:46 Ray Andrews
2024-04-10 18:39 ` Lawrence Velázquez
2024-04-10 19:05   ` Andreas Kähäri
2024-04-10 19:17     ` Ray Andrews
2024-04-10 19:12   ` Ray Andrews [this message]
2024-04-11  0:01     ` Lawrence Velázquez
2024-04-11  0:15       ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47548b8e-a5e6-4fbb-8b57-4f3055f22c91@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).