Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: string to array space problem in filenames
- X-seq: zsh-users 20504
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: string to array space problem in filenames
- Date: Thu, 3 Sep 2015 17:21:49 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=Km0cdpcpQPrwdWsqNcJE8NxfmKGOgG3/mRz5TaDz2o0=; b=d8hIHq3GiUt8x/BrX37FuzwZuCTRjiReRsez5i0ACaK0MJmr+0U05ixzUdp8V+tew0 fLM2tPq/J41Fo84Ee4U/kazEf9Mfcu1dThI9GspGkVas1WqUo5ZfITFxCbPi82h5/Bbt onOfAm6FD7I8YtvS3L5BD2A0i/LfQ+4/jdCZIKF4pi7dlnCwIJjUAUJnzZRaKkWLydtG wIIJmswCbd4rdyd9WjSvCkSUDj1joq31MXICTeP12dwGHrtOPZ/gwYLlMJukZY98YjzQ mbYDSJlLDA1dpqCzBIkCOpwuuMCO5e4kV+a2mj6AASm2pTWtHQAwjGdoom35ltlUpOnL OyGg==
- In-reply-to: <55E86E0C.1000806__15798.3473306105$1441295967$gmane$org@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Ray Andrews <rayandrews@xxxxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20150821215037.6b010cf7@ntlworld.com> <55DFC1E6.5090400@eastlink.ca> <CAHYJk3TNvPnByF7m4Pa=DB1Qyu5L6svnLS-uiZ5sqpfbti_-mQ@mail.gmail.com> <55E0AE60.9090706@eastlink.ca> <150828124334.ZM7129@torch.brasslantern.com> <55E7C084.2060505@eastlink.ca> <150902222539.ZM18111@torch.brasslantern.com> <55E86605.7080304@eastlink.ca> <CAHYJk3Rii53zG7HsZiTzDOFMkX4T9DyX+qf3+FGPHoA=K0RewA@mail.gmail.com> <55E86E0C.1000806__15798.3473306105$1441295967$gmane$org@eastlink.ca>
2015-09-03 08:58:04 -0700, Ray Andrews:
> On 09/03/2015 08:30 AM, Mikael Magnusson wrote:
>
> >-r is good to use as I explained in my other mail, -u2 means to
> >print to stderr which would be a very strange thing to do here,
> >since it won't go to 'file'.
>
> I was just typing a post to ask about that ... I'll take that on
> faith, however one further question:
>
> print -rl - "${array[@]}" > file
>
> ... do I or don't I like the double dash that seems to usually be there?
> And a few code specimens have shown no dash(es) at all there, which scares
> me since disaster is never far away from the unwary.
An annoying thing with print -l (and it's the same with its
standard equivalent printf '%s\n') is that you get the same
output for an empty list and a list of one empty element.
That is:
list=()
print -rl -- "$list[@]"
list=('')
print -rl -- "$list[@]"
both print one empty line.
so, strictly speaking, you need to write it:
println() {
[ "$#" -eq 0 ] ||
printf '%s\n' "$@"
}
println "$list[@]"
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author