#!/bin/sh
#
# mkscript - script to automate generation of executable shell scripts

file="$1"
SHELL="$2"

if [ -z "${file}" ]; then
  echo "No file name specified."
  exit
fi

if [ -e "${file}" ]; then
  echo "File already exists."
  exit
fi

printf "#!/bin/%s\n\nset -eu\n\n" "${SHELL:-sh}" >"${file}"

touch "${file}"
chmod +x "${file}"
exec "${EDITOR:-vi}" "${file}" '+$'
