From: Ian Jackson Date: Wed, 24 Oct 2018 10:24:36 +0000 (+0100) Subject: sa-init-db: Fix argument parsing X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=afe626cef69e788fdbbfb4857a99ead5f9e24e4f;p=osstest.git sa-init-db: Fix argument parsing 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 --- diff --git a/sa-init-db b/sa-init-db index bd9aa4a..2c97aab 100755 --- a/sa-init-db +++ b/sa-init-db @@ -18,18 +18,19 @@ set -e -o posix -usage(){ - cat <&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" <