有没有办法在交互式 shell 会话中使用 "native" Crystal 来确定它是否是 运行?

Is there a way of using "native" Crystal to be determine if it's running in an interactive shell session?

如果 Crystal 可执行文件是 运行,在交互式环境中确定它是否 运行 的推荐方法是什么?

例如:

`tty`.strip != "not a tty"

但是,使用原生 Crystal。

这是IO#tty?方法。

编译一个文件(foo.cr),内容为:

puts STDIN.tty?

运行 它来自 shell:

./foo              # => true
echo "foo" | ./foo # => false