aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/mysql.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-07-15 00:34:48 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-07-15 00:40:37 +1200
commit8947c4c99f4c1ad92f23e59e84b224cf35e4ff81 (patch)
tree70718ad01791f2ca67133376252cf69a693b14ea /bash/bashrc.d/mysql.bash
parentTerser `read -rd ''` idiom (diff)
downloaddotfiles-8947c4c99f4c1ad92f23e59e84b224cf35e4ff81.tar.gz
dotfiles-8947c4c99f4c1ad92f23e59e84b224cf35e4ff81.zip
Quote expansions within parameter expansions
I made the incorrect assumption that it was safe not to do this; expansions that include glob characters, for example, can cause problems.
Diffstat (limited to 'bash/bashrc.d/mysql.bash')
-rw-r--r--bash/bashrc.d/mysql.bash7
1 files changed, 3 insertions, 4 deletions
diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash
index 34debb1c..dd9ffe73 100644
--- a/bash/bashrc.d/mysql.bash
+++ b/bash/bashrc.d/mysql.bash
@@ -15,10 +15,9 @@ mysql() {
config=$HOME/.mysql/$1.cnf
if [[ -r $config ]] ; then
shift
- command mysql --defaults-extra-file="$config" "$@"
- else
- command mysql "$@"
+ set -- --defaults-extra-file="$config" "$@"
fi
+ command mysql "$@"
}
# Completion setup for MySQL for configured databases
@@ -44,7 +43,7 @@ _mysql() {
# Collect all the config file names, strip off leading path and .cnf
local -a cnfs
cnfs=("$dirname"/"${COMP_WORDS[COMP_CWORD]}"*.cnf)
- cnfs=("${cnfs[@]#$dirname/}")
+ cnfs=("${cnfs[@]#"$dirname"/}")
cnfs=("${cnfs[@]%.cnf}")
# Bail if no files to prevent empty output