Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: expanding parameters like echo/print builtins

On 12 May 2011 12:10, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On May 11,  7:43pm, Mikael Magnusson wrote:
> } Subject: Re: PATCH: expanding parameters like echo/print builtins
> }
> } What I meant was that the relation between V and g:: isn't documented,
> } but yeah, I did miss the whole list :). Here's a patch, minus the
> } renumbering of subsequent items.
> Renumbering the subsequent items is a nasty bit to leave out, because
> there are cross-references among the items that always get forgotten;
> I just fixed all of those up a few months ago.
> It might be better just to add this to item 12 rather than introduce
> a new number.

Ah, good point.

> } Any better names than echo-type expansion? :)
> Elsewhere these kinds of things are referred to as "escape sequences"
> but then so are %-dohickeys for prompts.  Probably would have been
> a good idea years ago to refer to the % forms as "expandos" or some
> such word ...
> But, given that they're all escapes, we could go with
> item(tt(12.) em(Escape sequence replacement))(
> First any prompt-style formatting from the tt((%)) family of flags is
> applied, then any replacements from the tt((g)) flag are performed.
> )
> The (g) stuff usually involves making the string *shorter* so to call
> it an "expansion" is a bit odd.

Also a good point, I can change it to "process escape sequences like
the echo builtin" also in the description of the g:: flag, that's what
the print description calls it.

> [Is there a potential conflict where
> (%) inserts something that (g) then incorrectly replaces, if you use
> both of them togher?]

Well, if (%) inserts something before (g) processes it, (g) will
replace it, but what would make it incorrect?
/tmp/\u3042% echo -E ${(g::%):-%~}

It is of course possible to move (g) somewhere else in the sequence if
wanted, I just figured it was closest logically to (%) and put it
there. (But if you don't like the order, all you have to do is
/tmp/\u3042% echo -E ${(%)${(g::):-%~}}

Mikael Magnusson

Messages sorted by: Reverse Date, Date, Thread, Author