I think I would have just written it in Perl, and remove the bash dependency (since bash is not installed, by default, on some minimal distros...Perl is also missing in such a case, but depending on both is certainly not better).