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

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



On Tue, 12 Oct 2010 18:56:49 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Is quoting the rest of the string really the correct thing to do?

My contention is that a string of the form "~/with space" is neither nowt
nor something.

> Consider ${${(D)foo}:r} or ${=${(D)foo}}.

${(D)${foo:r}} is the right way round, since the initial $foo is (by
hypothesis) a path understood by the OS, while ${(D)foo} isn't, even
without the quoting.  But why are you doing file operations on a
parameter and then turning it into something that's no longer a file
(or, perhaps better put given what :r is typically used for, that
doesn't allow you to construct a file name you can use in a shell
expression)?

I don't know what ${=${(D)foo}} is supposed to be useful for.

> Why do you believe 
> ${(Q)$(D)foo}} should be necessary to operate on the original
> string, modulo tilde contraction?  Is it because that's easier
> on a zsh script programmer than figuring out where to use (q)?

Yes.  With dynamic directory naming you can have
~[complexexpression]/stuff.  It's valid to have a "/" in the complex
expression.  It's not a simple obvious operation to get a correctly
formatted string even without that.

Under what circumstances do you think it's useful to have a tilde
expression that's not usable as a shell command line argument, anyway?
Surely this can only be cosmetic, in which case having to add (Q) if you
really want a string purely for display is perfectly reasonable?

> Perhaps steps 13 and 14 from the "rules" should be combined in
> some way, so (qD) together differs from either used alone?  

That looks a messier solution to me, though not unworkable given that
you also have the safe option of ~${(q)${(D)...}}.

-- 
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