From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 993 invoked by alias); 26 Nov 2012 13:11:29 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17442 Received: (qmail 28326 invoked from network); 26 Nov 2012 13:11:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) Date: Mon, 26 Nov 2012 13:01:20 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: Date prompt expansion Message-id: <20121126130120.63fcee9b@pwslap01u.europe.root.pri> In-reply-to: <50B362AC.4000203@internecto.net> References: <50B35385.8040409@internecto.net> <20121126114659.7ec8f1a8@pwslap01u.europe.root.pri> <50B362AC.4000203@internecto.net> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-TM-AS-MML: No On Mon, 26 Nov 2012 13:38:04 +0100 Mark van Dijk 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