It claimed to have a default db name, but it didn't. Rework the
option parsing to make the usage message true. (That saves me typing
sa-init-db standalone
and getting bizarre errors as sqlite tries to treat the shell script
`standalone' as if it were a database file.)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
set -e -o posix
-usage(){
- cat <<END
+badusage(){
+ cat <<END >&2
usage: ./sa-init-db [database]
END
+ exit 127
}
-if [ $# -ne 1 ] ; then
- usage >&2
- exit 1
-fi
-
-db="$1"
+case "$#.$*" in
+0.) db=standalone.db ;;
+1.-*) badusage ;;
+1.*) db="$1" ;;
+*) badusage ;;
+esac
sqlite3 "$db" <<END
CREATE TABLE flights (