Improve portability of script