From d2d3ca5617a12d7ff38a2f703011aa4997b2b996 Mon Sep 17 00:00:00 2001 From: Kevin Baensch Date: Wed, 18 Jan 2023 10:24:59 +0100 Subject: [PATCH] Use mysql CLI if in pipe mode or user specifies -c. --- script/myssh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/myssh b/script/myssh index a0ed5c1..06c5e42 100755 --- a/script/myssh +++ b/script/myssh @@ -13,6 +13,12 @@ SUBCOMMANDS:\n SYNTAX connect host [-u user] [-p password] [-c client] " +# Detect Pipe +if ! [ -t 1 ] +then + USE_CLI=true +fi + get_template_string() { if [ -z "$SQL_CLI_TEMPLATE" ] then @@ -138,7 +144,7 @@ set_host_env() { run_client() { if [ "$1" = 'mysql' ] then - if [ -d "/Applications/Sequel Ace.app" ] + if [ -d "/Applications/Sequel Ace.app" ] && [ "${USE_CLI}" != true ] then open "mysql://$2:$3@${SQL_PROXY_HOST}:6033" -a "Sequel Ace" elif which mysql >/dev/null 2>&1 @@ -191,6 +197,7 @@ case "${MAIN_OPTION}" in case "$o" in u) TARGET_HOST_USERNAME="$OPTARG" ;; p) TARGET_HOST_PASSWORD="$OPTARG" ;; + c) USE_CLI=true ;; esac done get_host "${TARGET_HOST}"