Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: can print but not assign to variable



On Wed, Oct 26, 2022, at 6:07 PM, Ray Andrews wrote:
> Ah!  Yes, I do know that.  Yes, we must force 'var' to become an array.  
> Stupid ... when I'm doing it with understanding, I get "( )" just fine, 
> but when I don't get the necessity I'm lost :(  Ok, all clear.

Additionally, your original attempt -- var=(#i)$W/rap -- is not
actually parsed as a plain old scalar assignment, but as a command
preceded by a temporary array assignment.  Here is a simpler
demonstration:

	% unsetopt EXTENDED_GLOB
	% fn() { typeset -p var }
	% cmd=fn
	% var=(#i)$cmd
	typeset -g -a var=( '#i' )

With EXTENDED_GLOB enabled, "#i" is treated as a glob, but this
fails because it is an invalid pattern.

	% setopt EXTENDED_GLOB
	% var=(#i)$cmd
	zsh: bad pattern: #i

-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author