From: Marc Chantreux <eiro@phear.org>
To: Zsh Users <zsh-users@zsh.org>
Subject: read options to slurp empty lines ?
Date: Fri, 1 Jun 2018 23:47:14 +0200 [thread overview]
Message-ID: <20180601214714.GA11281@prometheus.u-strasbg.fr> (raw)
hello people,
i'm very unhappy with the patch i made on uze.zsh today
https://github.com/zsh-uze/uze/commit/b695fff8d4b2b5dd91ca9033c8d98ac3c3badeef#diff-ea0555d620dfb73b2eda6e587c48d7b1L40
i use to have slurp function made like this
slurp () IFS=$'\n' read -r -d ' -A $1
so i am able to write
print -l foo bar bang | slurp them
# got them=( foo bar bang )
i recently saw that
print -l '' bar bang '' | slurp them
# got them=( bar bang )
# expected them=( '' bar bang '' )
i tried to patch it using some read options and
slurp () {
local it
local n=${1:-them}
set --
while { IFS= read -r it }
do
set -- "$@" "$it"
done
set -A $n "$@"
}
which is way much longer. did i miss something using read builtin ?
regards
marc
next reply other threads:[~2018-06-01 21:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 21:47 Marc Chantreux [this message]
2018-06-02 1:17 ` Bart Schaefer
2018-06-02 6:58 ` Marc Chantreux
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=20180601214714.GA11281@prometheus.u-strasbg.fr \
--to=eiro@phear.org \
--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).