zsh-users
 help / color / mirror / code / Atom feed
* read options to slurp empty lines ?
@ 2018-06-01 21:47 Marc Chantreux
  2018-06-02  1:17 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Chantreux @ 2018-06-01 21:47 UTC (permalink / raw)
  To: Zsh Users

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-02 22:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-01 21:47 read options to slurp empty lines ? Marc Chantreux
2018-06-02  1:17 ` Bart Schaefer
2018-06-02  6:58   ` Marc Chantreux
2018-06-02 22:06   ` Marc Chantreux

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).