# When called in bash like this,I want 'cat.rb' to exit immediately:ruby cat.rb# When called in bash like this,I want to see the word 'hello':echo hello | ruby cat.rb
如果我只有cat.rb包含puts gets,那么第一个示例将阻塞,等待交互式stdin上的EOF.我不想修改调用命令,但希望支持这两种行为.
解决方法 看看$stdin.tty?ruby cat.rb# $stdin.tty? -> trueecho hello | ruby cat.rb# $stdin.tty? -> false总结
以上是内存溢出为你收集整理的检测Ruby中的stdin内容全部内容,希望文章能够帮你解决检测Ruby中的stdin内容所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)