Given string foo, I want to store each of its field seperated by \n into elements of array bar. And I want to do this using read command, or any other command that is compatible with older versions of bash (which readarray isn't).
I tried this command:
IFS=$'\n' read -d '' -r -a bar <<< "$foo"
but it just returns error code 1.
Is there any command that I can use to accomplish what I want? I know I could do this iteratively but obviously just doing it with one command is preferred.