Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save loplex/921f4f694a97e4fea3ad97b9bfed297d to your computer and use it in GitHub Desktop.
Save loplex/921f4f694a97e4fea3ad97b9bfed297d to your computer and use it in GitHub Desktop.
#!/bin/bash
function sampleImput() {
printf "%s\0" 'a b' 'c d'
}
# using read:
unset arrA i; while IFS= read -r -d '' 'arrA[i++]'; do :; done < <(sampleImput)
declare -p arrA i
# using readarray:
unset arrB; IFS= readarray -d '' arrB < <(sampleImput)
declare -p arrB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment