From 9e70299fb9fe0d114d9991fd5abfffad8dfd0255 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 11 Apr 2018 13:25:54 +0300 Subject: mysql.sh: support $MYSQL_DATABASE --- %HOME%/.bash_utils/mysql.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to '%HOME%/.bash_utils') 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[@]}" ) -- cgit v1.2.3