How to find out from a ruby ​​script whether it was launched from the command line or from a non-interactive process?

How can I indicate from ruby ​​script whether it is running from the command line, for example:

> ruby myscript.rb

or from a non-interactive process, for example. hron?

+3
source share
1 answer

$stdin.tty? will return true if connected to the terminal otherwise false.

Is there a little additional information on the recommendation for using STDIN in Ruby?

+5
source

Source: https://habr.com/ru/post/1755319/


All Articles