/bin/sh on Ubuntu is dash, it is fast, but no-thrills and strictly POSIX compliant shell and therefore it does not know arrays. Arrays should not be used in combination with /bin/sh (on any system), if it does work it is pure happenstance.
Use /bin/bash or /bin/ksh (which is /bin/ksh93) instead..
LOL, I meant to say arrays.. Corrected in post.
On Ubuntu ksh is the real ksh, and I think on most modern Linux distributions the default ksh has become ksh93.