Replace `wait` sh script with an escript one