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

Re: read options to slurp empty lines ?



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