[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH 1/3] 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 <ian.jackson@xxxxxxxxxxxxx> --- sa-init-db | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sa-init-db b/sa-init-db index bd9aa4a4..2c97aaba 100755 --- a/sa-init-db +++ b/sa-init-db @@ -18,18 +18,19 @@ 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 ( -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |