Como controlar o mysql com zpty?

3

Eu tento escrever um script wrapper para o cliente do console mysql. Enquanto trabalhava nisso, me deparei com zpty. Parece perfeito.

Meu primeiro objetivo foi recuperar alguns conteúdos da tabela, mas eu já falhei em fazer isso. Existe algum comportamento realmente estranho.

Se eu executar o zsh e digitar

$ zmodload zsh/zpty
$ zpty -b MYSQL mysql DATABASE-NAME
$ zpty -r MYSQL

tudo funciona como esperado e

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 448
Server version: 5.5.54-0+deb8u1 (Debian)

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [DATABASE-NAME]> %

é impresso.

Se eu colocar as mesmas linhas de código em um shellscript

#!/bin/zsh
zmodload zsh/zpty
zpty -b MYSQL mysql DATABASE-NAME
zpty -r MYSQL

e executá-lo, nada é impresso.

Se eu remover o -b no shellscript

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 449
Serv

é impresso. Então o script congela.

Em geral, noto um comportamento muito incoerente. Isso é um inseto? O que estou fazendo errado?

    
por Michael Palm 13.03.2017 / 15:25

0 respostas