Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: surprise with echo
- X-seq: zsh-users 19621
- From: Lawrence Velázquez <larryv@xxxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: surprise with echo
- Date: Sat, 20 Dec 2014 00:08:07 -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=9mIPzfYroicY3qtGVnhLNYX 2Zy0=; b=KF4op74u8+6AkVtn1u7DW2fZ2x8cCZ3XDoWNAwr6Lo8O/BUkF16yO3V HDTPelbe0NJvMK4J8O4VcW/xqZ237lSdBhtGTnCFQbTp1r5YJ7QnvBOm836NM5aX jwdSSJB1MRJAA4h1KteaVyNAZcZN53OojZX6ix8qWIwoHNEGLfNo=
- In-reply-to: <5494F332.7000008@eastlink.ca>
- 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> <CABx2=D8EU+uFXizT99ETXMZKScrFAeyEezeV9NgsLe8=Sdv4Bg@mail.gmail.com> <20335.1418988086@thecus.kiddle.eu> <CABx2=D-a9SnuSUgopZMQMnMB=ve9WZ02+uFfOsee2WbOogkddQ@mail.gmail.com> <5494F332.7000008@eastlink.ca>
On Dec 19, 2014, at 10:55 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> My two cents would be (well, er, my 1/2 cent), that it should be the default, *but* that the little surprise should not be there
I believe Kurtis was saying that RC_QUOTES should be enabled by default, not RC_EXPAND_PARAM.
Having array substitution be distributive by default would be much more of a "little surprise" at this point.
> b) because it seems harsh to kill an entire string because one element in it is null.
You still don't understand what's going on. The expansion only results in a null result *if the array itself is empty*. Null *elements* do not produce the same behavior.
% emulate zsh && setopt RC_EXPAND_PARAM
% foo=()
% echo aaa${foo}bbb
% foo=('')
% echo aaa${foo}bbb
aaabbb
% foo=('' '' '')
% echo aaa${foo}bbb
aaabbb aaabbb aaabbb
%
> c) Because the doctrine of least surprise should be followed.
Agreed. That's why enabling RC_EXPAND_PARAM by default should never happen.
> OTOH Bart just showed how the surprise can be avoided so ....
It's only a surprise if you enable the option without understanding what it does first. I actually think that zsh's behavior is more consistent and sensible. Why does it make sense to treat an empty array in the same way as an array consisting of a single null element? Do you treat null sets that cavalierly?
Consider this contrived-ish example:
% include_dirs=(/opt/local/include /usr/include /usr/local/include)
% clang -I${include_dirs} test.c
The expansion here would be "clang -I/opt/local/include -I/usr/include -I/usr/local/include test.c". But:
% include_dirs=()
% clang -I${include_dirs} test.c
What would be the point of this expanding to "clang -I test.c"? It seems entirely reasonable to drop that word entirely and expand to "clang test.c", which is what actually happens.
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author