Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is this a bug? Why not?
- X-seq: zsh-workers 27849
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Is this a bug? Why not?
- Date: Tue, 30 Mar 2010 23:06:02 -0700
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d200912; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=73sjI73c4O0ZBtF/Ufydp1GggR6+63/W7XyDoB9QsIY=; b=cCCTWQVoiixhSSMemhXKON3iVYazcfatcSj1ak1v32A4Ws2pbRLCD7IXiOxRu5sM6QrxiU3D1y7a+37BjCz6bbHYrixDGI+XR3YQe5yWtDuL5m9fPca/NWRAeFDGtONBakoGjwQ1F0sTi6qrrL2UpV5gF6CN+TkGRaIqd1WKKgA=;
- In-reply-to: <100330224612.ZM1818@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <100330224612.ZM1818@xxxxxxxxxxxxxxxxxxxxxx>
On 2010-03-30 at 22:46 -0700, Bart Schaefer wrote:
> macadamia% print $ZSH_VERSION $ZSH_PATCHLEVEL
> 4.3.10-dev-1 1.4947
> macadamia% print ${var-???}
> CVS Doc Etc Src
> macadamia% print ${${var}-???}
>
> macadamia% print ${${var}+???}
> CVS Doc Etc Src
> macadamia% print ${${var}:-???}
> CVS Doc Etc Src
> macadamia% print ${${var}:+???}
>
> macadamia%
So the string ${var} when treated as a variable-name is empty but
defined? The four expansions with a nested ${var} are entirely
consistent with the behaviour when expanding a variable which is defined
with a value of length 0.
Seems unusual, but consistent.
In bash, ksh, bad substitution. In ksh93, it gets weird:
$ echo ${var-???}
OSM SCM bin dbg doc etc lib man src tmp www
$ echo ${${var}-???}
ksh93: syntax error: `!' unexpected
The ksh reference-name expansion made me think of the somewhat opposite
expansion in zsh, (P)var ...
Hrm, zsh 4.3.10 1.4705:
% print ${(P)-???}
zsh: 0239BCJPXZgiklms: ??
% print ${(P)+???}
zsh: bad substitution
% print ${(P):-???}
OSM SCM bin dbg doc etc lib man src tmp www
% print ${(P):+???}
%
Strange that the first entry is somehow tying into expanding $- for the
shell options ...
% print ${-}
0239BCJPXZgiklms
% print ${(P)-}
% print ${(P)-?}
zsh: 0239BCJPXZgiklms: parameter not set
That strikes me as dubious. You?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author