Generates a script with either the provided shebang or with a shebang invoking bash, and with the result of the provided function.