03 - testing whether a program is running interactively.rb
来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 18 行
RB
18 行
#!/usr/bin/ruby -w# interactive_or_not.rbif STDIN.tty? puts "Let me be the first to welcome my human overlords."else puts "How goes the revolution, brother software?"end#---$ ./interactive_or_not.rbLet me be the first to welcome my human overlords.$ echo "Some data" | interactive_or_not.rbHow goes the revolution, brother software?$ ./interactive_or_not.rb < input_fileHow goes the revolution, brother software?#---
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?