Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Parameter + prompt expansion %D{%T.%.} parser issue
- X-seq: zsh-workers 38884
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Roland Eggner <edvz2@xxxxxxxxxxxxxxxxxx>, zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: Parameter + prompt expansion %D{%T.%.} parser issue
- Date: Mon, 18 Jul 2016 20:48:15 -0700
- 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==
- In-reply-to: <CAHYJk3QPHyH30z+iZ8=o9WPviA4F_=sFMFwEeVdBq65GkWEddw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160718203149.GA11086@mobil.systemanalysen.net> <CAHYJk3QPHyH30z+iZ8=o9WPviA4F_=sFMFwEeVdBq65GkWEddw@mail.gmail.com>
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@xxxxxxxxxxxxxxxxxx> 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.%.} %~"}"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author