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

Re: ${(q)...} for newline



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