diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-30 14:59:13 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-30 14:59:13 +1200 |
commit | 6ccd74f78e84401212efc11e72ef624c5f201c80 (patch) | |
tree | 8a615ea3d4d0a92414790d0e13af8fdac4a849dd /sh | |
parent | Remove fixed completion issue (diff) | |
download | dotfiles-6ccd74f78e84401212efc11e72ef624c5f201c80.tar.gz dotfiles-6ccd74f78e84401212efc11e72ef624c5f201c80.zip |
Fix mysql()
Diffstat (limited to 'sh')
-rw-r--r-- | sh/shrc.d/mysql.sh | 18 |
1 files changed, 12 insertions, 6 deletions
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 "$@" } |