Bash: show prompts if arguments weren't provided
You can shorten it a bit by using a function:
#!/bin/bash
ask()
{
declare -g $1="$2"
if [ -z "${!1}" ]; then
echo "$3"
read $1
fi
}
ask PROJECT_DIR "$1" "Directory where project resides:"
ask SITE_NAME "$2" "Name of the website:"
ask ADMIN_PWD "$3" "Admin password:"
ask THEME_DIR "$4" "Directory of the theme:"
ask THEME_NAME "$5" "Name of the theme:"
echo "$PROJECT_DIR $SITE_NAME"
This requires bash
though and won't work in sh
.