Skip to content

Instantly share code, notes, and snippets.

@yoku0825
Created September 26, 2022 14:41
Show Gist options
  • Save yoku0825/2629031b69c06377f4dd5b5dc7552ef3 to your computer and use it in GitHub Desktop.
Save yoku0825/2629031b69c06377f4dd5b5dc7552ef3 to your computer and use it in GitHub Desktop.
mysqlコマンドラインクライアントって、自分の出力がパイプかどうかどうやって判定してるんだろ
$ strace -e write /usr/mysql/8.0.30/bin/mysql -S /usr/mysql/8.0.30/data/mysql.sock -P 64080 --prompt="mysql80 \C> " -e "SELECT 1"
write(1, "+---+\n", 6+---+
) = 6
write(1, "| 1 |\n", 6| 1 |
) = 6
write(1, "+---+\n", 6+---+
) = 6
write(1, "| 1 |\n", 6| 1 |
) = 6
write(1, "+---+\n", 6+---+
) = 6
+++ exited with 0 +++
$ strace -e write /usr/mysql/8.0.30/bin/mysql -S /usr/mysql/8.0.30/data/mysql.sock -P 64080 --prompt="mysql80 \C> " -e "SELECT 1" | cat
write(1, "1\n1\n", 41
1
) = 4
+++ exited with 0 +++
@yoku0825
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment