zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: zsh-workers@zsh.org
Subject: Re: print -D and ${(D)} quoting
Date: Wed, 13 Oct 2010 10:04:35 +0100	[thread overview]
Message-ID: <20101013100435.4d3ae3f7@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <101012185649.ZM20220@torch.brasslantern.com>

On Tue, 12 Oct 2010 18:56:49 -0700
Bart Schaefer <schaefer@brasslantern.com> 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@csr.com>            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


  reply	other threads:[~2010-10-13  9:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-12 16:52 Peter Stephenson
2010-10-12 20:53 ` Peter Stephenson
2010-10-13  1:56   ` Bart Schaefer
2010-10-13  9:04     ` Peter Stephenson [this message]
2010-10-13 16:14       ` Bart Schaefer
2010-10-13 16:45         ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101013100435.4d3ae3f7@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).