diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2018-04-11 13:25:54 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2018-04-11 13:25:54 +0300 |
commit | 9e70299fb9fe0d114d9991fd5abfffad8dfd0255 (patch) | |
tree | 3f782a7b8d3042f9ea54b71de69d7ec4df4dc67d | |
parent | add mysql.sh (diff) | |
download | linux-home-9e70299fb9fe0d114d9991fd5abfffad8dfd0255.tar.gz linux-home-9e70299fb9fe0d114d9991fd5abfffad8dfd0255.zip |
mysql.sh: support $MYSQL_DATABASE
Diffstat (limited to '')
-rw-r--r-- | %HOME%/.bash_utils/mysql.sh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/%HOME%/.bash_utils/mysql.sh b/%HOME%/.bash_utils/mysql.sh index e5a02fe..b70a8b3 100644 --- a/%HOME%/.bash_utils/mysql.sh +++ b/%HOME%/.bash_utils/mysql.sh @@ -26,16 +26,20 @@ runsql() ( _runsql_check_var MYSQL_USER MYSQL_PASSWORD MYSQL_HOST local MYSQL_PORT="${MYSQL_PORT:-3306}" - local -a statement_list + local -a args local stmt for stmt; do - statement_list+=(-e "$stmt") + args+=(-e "$stmt") done + if [ -n "${MYSQL_DATABASE:+x}" ]; then + args+=("$MYSQL_DATABASE") + fi + mysql \ --user="$MYSQL_USER" \ --password="$MYSQL_PASSWORD" \ --host="$MYSQL_HOST" \ --port="$MYSQL_PORT" \ - "${statement_list[@]}" + "${args[@]}" ) |