Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from mail-pa0-f50.google.com by f.primenet.com.au (envelope-from <schaefer@brasslantern.com>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(209.85.220.50):SA:0(0.0/5.0):. 
 Processed in 0.141796 secs); 19 Jul 2016 03:47:51 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID
	autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: schaefer@brasslantern.com
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version;
        bh=NOxerAnn/2otSEv8ib7joCPyBdGMVkqNs8KZFnsuPKE=;
        b=U3OQBgyi7StM+BtN7f6qcPEY4HoQqKHBazQvcVAIFgvdoD4DtbH09bs5FmYXqzPk+g
         5lAuBdPB37K15JqnIlP7taYys0DWUlYBD09sRPi7N8aKq2QkoeIXOc/ZqEFS2nA+yqhr
         FnLQARdCKlLB31GlWvwqh/8+mbYhFEThwgUQGckziy+7N8QJWO8XS0REasdRO2Enn78s
         rHG1umD6+znwDiwf7fh+dLFVZXVgWvDPmVmmlMBCJlJ2n3mCrs3J0YVrXpiYPswITExo
         zHHhnZJ9yrLnZldYW3ccIntvK5QM4W0ZSpjKPxU3viHbs4Y5Z1JFT+ma3UBZa0vRyVVf
         gYOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version;
        bh=NOxerAnn/2otSEv8ib7joCPyBdGMVkqNs8KZFnsuPKE=;
        b=kDJ8VREFwBOCQBS/a3G1iH/BWdXusV0bV7kwP8t7l7d4AJJfvIgR7CZbFFE33d3Yyk
         CWQ7cTAtntBFCFU02r/vl6U9l/T9EtdNaA42LAsN1ku4C4dW6U+n4HXhGJcdDTvCjt+N
         DfWrkh0Z2+O36OK850lU9lPYKugt1cT5D9z2pzXAL47FwYY3IAUCEMLe1WzO2oTP+XZp
         9ekAU4UINsRo8KPuviUQclNYHvhwvyjtTnak5v5UQhJcYNIe7qykSTfbhAEi3LAjy2xu
         L/LquWC/NGh8ibEdQC53CAoD3ga5yR1hV7H4Dy/OkIzbW4Sk8ZuIEIlkZxEuFx4+prut
         c3kw==
X-Gm-Message-State: ALyK8tJ+TdPy94QaAfMaN65b3f1iX1j84PQfRz6zBaOExRJr/y7V1vdk1qUSdRnX7ldctA==
X-Received: by 10.66.216.41 with SMTP id on9mr62362570pac.86.1468900063657;
        Mon, 18 Jul 2016 20:47:43 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160718204815.ZM6266@torch.brasslantern.com>
Date: Mon, 18 Jul 2016 20:48:15 -0700
In-Reply-To: <CAHYJk3QPHyH30z+iZ8=o9WPviA4F_=sFMFwEeVdBq65GkWEddw@mail.gmail.com>
Comments: In reply to Mikael Magnusson <mikachu@gmail.com>
        "Re: Parameter + prompt expansion %D{%T.%.} parser issue" (Jul 19,  2:21am)
References: <20160718203149.GA11086@mobil.systemanalysen.net> 
	<CAHYJk3QPHyH30z+iZ8=o9WPviA4F_=sFMFwEeVdBq65GkWEddw@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Roland Eggner <edvz2@systemanalysen.net>,
        zsh workers <zsh-workers@zsh.org>
Subject: Re: Parameter + prompt expansion %D{%T.%.} parser issue
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 38884

On Jul 19,  2:21am, Mikael Magnusson wrote:
} Subject: Re: Parameter + prompt expansion %D{%T.%.} parser issue
}
} On Mon, Jul 18, 2016 at 10:31 PM, Roland Eggner
} <edvz2@systemanalysen.net> wrote:
} > emulate -R zsh -c 'print -l ${(%):-%D{%T.%.} %~} "${(%):-%D{%T.%.} %~}" ${(%):-"%D{%T.%.} %~"}'
} >
} > Observed:
} > 22:03:02.324 ~
} > 22:03:02.324 %~}
} > 22:03:02.324 ~
} >
} > Usage error?  Bug?  Feature?
} 
} Usage error, but it's kind of hard to understand what's going on there
} admittedly. When ${} is unquoted, then the parser "knows" which {}
} belong together

That's not quite right either.

You can get a better idea what's happening this way:

torch% setopt ignorebraces
torch% print -l ${(%):-%D{%T.%.} %~} "${(%):-%D{%T.%.} %~}" ${(%):-"%D{%T.%.} %~"}
20:33:34.148
%~}
20:33:34.148 %~}
20:33:34.148 ~

In the first (unquoted) case, with the default setopts (no_ignorebraces),
the substring {%T.%.} is parsed like a brace expansion, but then does not
expand because there are no commas.  So it's accidental that it works the
way expected.  With ignorebraces you see parameter expansion end at the
first close brace, leaving %~} to split into another argument to print.

The third form with the part after :- in quotes is really the only right
way, particularly given the space before %~.  Note that with parameter
expansions in all but the most antiquated versions of the shell you can
actually nest double quotes:

    print "${(%):-"%D{%T.%.} %~"}"

