Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${(q)...} for newline
- X-seq: zsh-workers 27966
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx (Zsh hackers list)
- Subject: Re: ${(q)...} for newline
- Date: Sun, 23 May 2010 21:45:39 +0100
- In-reply-to: Message from Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> of "Sun, 23 May 2010 20:58:40 BST." <10739.1274644720@pws-pc>
- 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
Peter Stephenson wrote:
> Param-style simple (i.e. backslash) quoting of a newline appends a real
> newline in double quotes. It seems to me it would occasion far fewer
> surprises if this never output a literal newline, so this uses $'\n'.
Also, would I be right in thinking this is an accident waiting to
happen?
% foo=(one '' three)
% print ${(q)foo}
one three
Certainly
% printf "%q\n" ''
which uses the same quoting internally is incompatible with what bash
does (it outputs ''). It looks like in both cases (and all explicit
uses of backslash-quoting --- completion is different) empty strings
might be better turned into an explicit ''.
Is there a case where this breaks something? I can't see one unless
you're explicitly relying on a particular result from quoting, which
seems an unhealthy thing to do. However, there may be special cases I
haven't thought of (there usually are with quoting).
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author