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

Re: print -D and ${(D)} quoting



On Wed, 13 Oct 2010 09:14:42 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> The ONLY reason I understand for using (D) is for human consumption,
> e.g., for display, so from my point of view (Q) is never not required.

Ah, this is probably the key point of why we're looking at this
differently.  No, the resulting string is used in completion.
So the intention is for the munged value to be both
useful and readable.

The case I'm interested in (and this is actually the only time I've used
the (D) flag so far, so I can't really compare with other possible uses)
is:

- take PWD
- save the value to a file
- use that value later on for completion

but in the process tidy up the value to something that's more readable
for the user, so doing the ~ contraction. (It doesn't really matter here
whether that's at the second or third step, in fact it's at the third).

One oddity here is that we're completing the full path in one go --- the
choices are absolute paths which could be anywhere in the file system.
This is why having a compact prefix becomes important.

In this particular case it's clear cut that either I supply
a raw file string, and allow completion to do the quoting, or I
supply a properly quoted command line argument, and make completion
insert it literally, since completion will either quote everything or
nothing.

So the new code gets me "~/with\ space" or whatever, and I
tell completion to insert that literally.

I don't necessarily know this is going to be widely used but I
still don't a good example of why doing it differently is likely to be
more useful.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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