zsh-users
 help / color / mirror / code / Atom feed
From: Marc Chantreux <eiro@phear.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: read options to slurp empty lines ?
Date: Sat, 2 Jun 2018 08:58:43 +0200	[thread overview]
Message-ID: <20180602065843.GA22633@prometheus.u-strasbg.fr> (raw)
In-Reply-To: <CAH+w=7bUdOB2DjCZmf5zWhL-9dM0ScSt6zPzuAmJK3EmEDsiyQ@mail.gmail.com>

> > slurp     () IFS=$'\n' read -r -d ' -A $1
> I presume that to be a typo or cut-and-paste error because you have an
> unmatched single quote there.

indeed!

    slurp     () IFS=$'\n' read -r -d '' -A $1

> % typeset -p them
> typeset -a them=( bar bang '' )

typeset -p is awesome! thanks for this :)

> The behavior of "read" is to collapse multiple consecutive occurrences
> of $IFS characters into a single one.

and then i feel dump because i know it :(

> Only that there's no simple way to make it do what you want. :-)
> You're probably looking for this:

> slurp() {
>   local REPLY
>   IFS= read -d '' &&
>   set -A ${1:-reply} "${(@f)REPLY}"
> }

much more elegant that mine. thank you!
marc


  reply	other threads:[~2018-06-02  6:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 21:47 Marc Chantreux
2018-06-02  1:17 ` Bart Schaefer
2018-06-02  6:58   ` Marc Chantreux [this message]
2018-06-02 22:06   ` Marc Chantreux

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=20180602065843.GA22633@prometheus.u-strasbg.fr \
    --to=eiro@phear.org \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@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).