fork(2) download
  1. append_to_array() {
  2. declare -n _dest="$1"
  3. _dest+=( "$(</dev/stdin)" )
  4. }
  5.  
  6. append_to_array data <<'END'
  7. {
  8. "my": "first doc"
  9. }
  10. END
  11.  
  12. append_to_array data <<'END'
  13. {
  14. "my": "second doc"
  15. }
  16. END
  17.  
  18. declare -p data
Success #stdin #stdout 0.01s 5444KB
stdin
Standard input is empty
stdout
declare -a data=([0]=$'{\n"my": "first doc"\n}' [1]=$'{\n"my": "second doc"\n}')