zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-users@zsh.org
Subject: Re: Date prompt expansion
Date: Mon, 26 Nov 2012 13:01:20 +0000	[thread overview]
Message-ID: <20121126130120.63fcee9b@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <50B362AC.4000203@internecto.net>

On Mon, 26 Nov 2012 13:38:04 +0100
Mark van Dijk <lists+zsh@internecto.net> wrote:
> I noticed something odd when I was trying to fill an associated array
> with these prompt expansions and the behaviour replicates into
> non-array variable assignments too. I suspect this is caused by a bug
> somewhere..
> typeset -A datetime DATETIME DateTime dATEtIME
> datetime=("month"     "${(%):-%D{"%m"}}"
>           "day"       "${(%):-%D{"%d"}}"
>           "ymdt"      "${(%):-%D{"%y%m%dT%H:%M"}}")
>
> datetime[ymdt]: 121126T13:35}
> datetime[day]: 26}
> datetime[month]: 11}
> DATETIME[ymdt]: 121126T13:35}
> DATETIME[day]: 26}
> DATETIME[month]: 11}
> 
> ^ notice the } at the end

The parameter expansion is terminated by the first "}" it comes across.
The "%D{" is then not terminated but it works anyway since it runs to
the end of the expression.  The remaining "}" is then just a normal
part of the string.  The easiest fix is probably to move the quotes:

datetime=("month"     "${(%):-"%D{%m}"}"
          "day"       "${(%):-"%D{%d}"}"
          "ymdt"      "${(%):-"%D{%y%m%dT%H:%M}"}")

pws


  reply	other threads:[~2012-11-26 13:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26 11:33 Mark van Dijk
2012-11-26 11:46 ` Peter Stephenson
2012-11-26 12:38   ` Mark van Dijk
2012-11-26 13:01     ` Peter Stephenson [this message]
2012-11-26 16:15   ` Aaron Schrab

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=20121126130120.63fcee9b@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-users@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).