Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: surprise with echo
- X-seq: zsh-users 19582
- From: Lawrence Velázquez <larryv@xxxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: surprise with echo
- Date: Thu, 18 Dec 2014 22:20:10 -0500
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:content-type:mime-version :subject:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to; s=smtpout; bh=Jo5e62TqgpeN9rXy8a9PiCI Pul4=; b=bNs1edkpYQHyWj6sclPVOmqU6o7dF7PuHgOYQijx5f60PFWRokyEjwY hOJccUq5Q4fnKrgAZxZLEpnFgRfZk9L8BzRLv8ZVC+ViQzZb/s+922i0nzKgQaVi yrAi2uYGQzCtOIJZvJfyUf3OHbjdQO1ggThHOZ0/G6b7ovoRExmI=
- In-reply-to: <141218190653.ZM16331@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <54937E5B.2020008@eastlink.ca> <141218190653.ZM16331@torch.brasslantern.com>
On Dec 18, 2014, at 10:06 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Dec 18, 5:24pm, Ray Andrews wrote:
>
> } Can that be prevented?
>
> Only by turning off the option, or by doing e.g. ${@:-''} so that the
> expansion is the empty string rather than the empty array.
Also note that "preventing" it would amount to treating an empty array
the same as an array containing a single null value, which is currently
not the case:
% emulate zsh && setopt RC_EXPAND_PARAM
% foo=()
% echo "abc${foo[*]}def"
abcdef
% echo "abc${foo[@]}def"
% foo=('')
% echo "abc${foo[*]}def"
abcdef
% echo "abc${foo[@]}def"
abcdef
You're making quite a few assumptions about how positional parameters
and array substitution work. For instance, the fact that you're using
double quotes (which affects the expansion of $foo[*] versus $foo[@]) is
clouding your understanding of how RC_EXPAND_PARAM works. Observe:
% emulate zsh && setopt RC_EXPAND_PARAM
% foo=()
% echo "abc${foo[*]}def"
abcdef
% echo abc${foo[*]}def
%
Please read zshparam(1).
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author