zsh-workers
 help / color / mirror / code / Atom feed
From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@zsh.org
Subject: Re: Is this a bug? Why not?
Date: Tue, 30 Mar 2010 23:06:02 -0700	[thread overview]
Message-ID: <20100331060602.GA91691@redoubt.spodhuis.org> (raw)
In-Reply-To: <100330224612.ZM1818@torch.brasslantern.com>

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?


  reply	other threads:[~2010-03-31  6:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31  5:46 Bart Schaefer
2010-03-31  6:06 ` Phil Pennock [this message]
2010-03-31 15:11   ` Bart Schaefer
2010-04-01  8:26     ` Phil Pennock
2010-04-01 14:36       ` Bart Schaefer
2010-04-01 21:57         ` Phil Pennock
2010-04-01 22:51           ` Bart Schaefer
2010-04-09 14:37             ` Peter Stephenson
2010-04-17 13:06               ` Mikael Magnusson
2010-04-18 19:11                 ` Peter Stephenson

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=20100331060602.GA91691@redoubt.spodhuis.org \
    --to=zsh-workers+phil.pennock@spodhuis.org \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@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).