Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${(q)...} for newline
- X-seq: zsh-workers 27972
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: ${(q)...} for newline
- Date: Tue, 25 May 2010 14:25:13 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=dYtVl6x24sdg7xQXA5XH62SbO6rg9o2KZbACcVpTKr0eJgiK7khvurxTAslxBmNoXS45Ny00//+b200Xq5xvjAnPq6G6wJekGsgzgnTqILLgO0OYj4MvG/Ec94M+EwGQZEvyFaSJCyqOIN3jdxAIAtde7Z6zo6NEFfExAQX0Rxk= ;
- In-reply-to: <201005232045.o4NKjdLO027329@xxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <p.w.stephenson@xxxxxxxxxxxx> <10739.1274644720@pws-pc> <201005232045.o4NKjdLO027329@xxxxxxxxxxxxxxxxxxx>
2010-05-23 21:45:39 +0100, Peter Stephenson:
> 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 ''.
[...]
Not in the first case though, as array expansion removes the
empty elements. But in "${(@q)foo}" yes maybe, at least to be
consistent with bash and ksh93 printf %q.
$ zsh -c 'a=(a "" b); printf "<%s>\n" ${(q)a}'
<a>
<b>
$ zsh -c 'a=(a "" b); printf "<%s>\n" "${(q@)a}"'
<a>
<>
<b>
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author