In a bash script, I would like to transform a string containing variable separated by ":" into an array.
I see that the proposed approach is usually
IFS=: read -r -a myarray <<< "$mystring"
I used instead a command that looks simpler to me:
IFS=: myarray=($mystring)
Moreover on my PC it works. See the script hereunder
#!/bin/bash
mystring="var01:var02:var03:var04"
IFS=: myarray=($mystring)
echo "first variable is" "${myarray[0]}"
echo "second variable is" "${myarray[1]}"
echo "..."
output is
first variable is var01
second variable is var02
...
However, as I did not found such example on the web, I'm not sure it's correct...
What would be the issue of using this in bash script ? Is it compliant with standard ?
Thanks for your advice.