diff options
Diffstat (limited to '%HOME%')
-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[@]}" ) |