fix script to work with arrays using bash instead of sh

Change-Id: I5a17cc90f8b523d9d7899bb4367da3acfbf3e002
Merge remote-tracking branch 'cm/cm-10.1' into bollox

Change-Id: Id88ca681d906d006723365b65e7aacf23c932029