From 6ccd74f78e84401212efc11e72ef624c5f201c80 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 30 Aug 2016 14:59:13 +1200 Subject: Fix mysql() --- sh/shrc.d/mysql.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'sh') diff --git a/sh/shrc.d/mysql.sh b/sh/shrc.d/mysql.sh index d37c3ead..abb496d2 100644 --- a/sh/shrc.d/mysql.sh +++ b/sh/shrc.d/mysql.sh @@ -1,5 +1,8 @@ -# If a file ~/.mysql/$1.cnf exists, call mysql(1) using that file. Otherwise -# just run MySQL with given args. Use restrictive permissions on these files. +# If a file ~/.mysql/$1.cnf exists, call mysql(1) using that file, discarding +# the rest of the arguments. Otherwise just run MySQL with given args. Use +# restrictive permissions on these files. Doesn't allow filenames beginning +# with hyphens. +# # Examples: # # [client] @@ -11,9 +14,12 @@ # database=bar # mysql() { - if [ -f "$HOME/.mysql/$1".cnf ] ; then - shift - set -- --defaults-extra-file="$HOME/.mysql/$1".cnf "$@" - fi + case $1 in + -*) ;; + *) + [ -f "$HOME/.mysql/$1".cnf ] && + set -- --defaults-extra-file="$HOME/.mysql/$1".cnf + ;; + esac command mysql "$@" } -- cgit v1.2.3