Convert zsh script to posix sh