Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: read options to slurp empty lines ?
- X-seq: zsh-users 23426
- From: Marc Chantreux <eiro@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: read options to slurp empty lines ?
- Date: Sat, 2 Jun 2018 08:58:43 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-filter: OpenDKIM Filter v2.10.3 aurora-borealis.phear.org 75CCA10A82
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=phear.org; s=20180217; t=1527922725; bh=YISJ7iu/anAHdb1xm3Skwz+FdFgfQX18pJQn+PXv/Ps=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a1g9WZVTeu+m8ysLPmV5JG2LgxdZWPZn6X+DK3C5c/KjNFCx8MhCnDT93Bl+Xvacg Pm5IGl6nKBhhVZ20JIvNi1vvECcUplnPkKWfOSOjAR6bXJZs3+oJQ2/O7q5urY5EQi olTV3Voyv3UnCtDkDD7sroEadVuwOvW78d/CTh6AIc0/4MdIqdB/4MLMt+53ncND71 XHBPCFJ1ZZ22tTrnwv/YxAl60EyMe0EhJXdO12YtcyIrP473ROzPg3fReE3Pc0gBQ+ KDSBOypJa1gkUOYDLBxZxwLsxdC7M+0UtwgEKqSfNq/apXLPQAPUV1SwzPWtTYDhhF XdEsqJM109Ihg==
- In-reply-to: <CAH+w=7bUdOB2DjCZmf5zWhL-9dM0ScSt6zPzuAmJK3EmEDsiyQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20180601214714.GA11281@prometheus.u-strasbg.fr> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author