I am trying to initialize read an array by splitting a variable.
x=abc:def:gh
declare -a xa
# I want xa[0] = abc, xa[1] = def, and so on
IFS=: read -a xa <<< $x
echo ${#xa[@]} $xa ######### the above did not work
1 abc def gh
# but type the same value from console?
IFS=: read -a xa
abc:def:gh ########## this is what I typed in
echo ${#xa[@]} $xa ######### this worked
3 abc
How do put IFS to work when reading in a variable using <<< ?
Will appreciate your suggestions.
Also, here is my actual problem, just in case there are smarter solutions to it. I use SVN and different people are interested in knowing about different set of paths. In SVN post-commit, I want to filter the list of changes and raise an email to different groups of people according to their desires. So I thought I would set up something like below in hooks-env
NOTIFY_LIST=mailinglist:grep options:grep options:......
and then, in post-commit, parse the svnlook data to see if there was any candidate email. Is there a declarative way to say that a change in such and such paths are of interest to such and such lists of people?
Thanks Dinesh
edit: tried combination of IFS and simply xa=($x)
. So it appears IFS=:
cannot be combined profitably with read. So I have a way to get my job done, but still curious what's happening?
IFS=: xa=($x) # the array is populated as expected
IFS=b xa=($x) # the array is populated as expected
Thanks again.