Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

read options to slurp empty lines ?



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



Messages sorted by: Reverse Date, Date, Thread, Author